jupyter notebook running kernel in different env

前端 未结 5 1759
醉酒成梦
醉酒成梦 2020-11-28 01:11

I\'ve gotten myself into some kind of horrible virtualenv mess. Help?!

I manage environments with conda. Until recently, I only had a python2 jupyter

5条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 02:02

    This is a tricky part of ipython / Jupyter. The set of kernels available are independent of what your virtualenv is when you start jupyter Notebook. The trick is setting up the the ipykernel package in the environment you want to identify itself uniquely to jupyter. From docs on multiple ipykernels,

    source activate ENVNAME
    pip install ipykernel
    python -m ipykernel install --user --name ENVNAME --display-name "Python (whatever you want to call it)"
    

    If you only want to have a single Python 3 kernel, from the conda environment, just use python -m ipykernel install --user and it will reset the default python to the one in the virtualenv.

    And yes, you will need to restart the kernel and re-run the prior steps.

    See Also Using both Python 2.x and Python 3.x in IPython Notebook

提交回复
热议问题