怎么在jupyter中加入python 3 kernel

2025-03-12 15:29:33
推荐回答(1个)
回答1:

Make sure you have ipykernel installed and use ipython kernel install to drop the kernelspec in the right location for python2. Then ipython3 kernel install for Python3. Now you should be able to chose between the 2 kernels regardless of whether you use jupyter notebook, ipython notebook or ipython3 notebook (the later two are deprecated).
Note that if you want to install for a specific Python executable you can use the following trick:
path/to/python -m ipykernel install

This works when using environments (venv,conda,...) and the let you name your kernel (see --help). So you can do
conda create -n py36-test python=3.6
source activate py36-test
python -m ipykernel install --name py36-test
source deactivate

And now you get a kernel named py36-test in your dropdown menus, along the other ones.
See Using both Python 2.x and Python 3.x in IPython Notebook which has more recent information.