如何将python3内核添加到jupyter(IPython) [英] How do I add python3 kernel to jupyter (IPython)
问题描述
我的 Jupyter
安装了 python 2
内核的笔记本。我不懂为什么。我做安装时可能搞砸了。我已经安装了 python 3
。如何将其添加到 Jupyter
?
这是默认 Jupyter
与 python3 -m install jupyter
一起打开并在浏览器中打开的屏幕截图使用 jupyter notebook
,如下所示:
My Jupyter
notebooks installed with python 2
kernel. I do not understand why. I might have messed something up when I did the install. I already have python 3
installed. How can I add it to Jupyter
?
Here's a screenshot of what the default Jupyter
insalled with python3 -m install jupyter
and opened in the browser with jupyter notebook
looks like:
推荐答案
确保已安装 ipykernel
并使用 ipython内核安装
删除kernelspec在python2的正确位置。然后为Python3 ipython3内核安装
。现在你应该可以在两个内核之间进行选择,无论你是否使用 jupyter notebook
, ipython notebook
或 ipython3 notebook
(不推荐使用后两个)。
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).
请注意,如果要为特定的Python可执行文件安装,可以使用以下技巧:
Note that if you want to install for a specific Python executable you can use the following trick:
path/to/python -m ipykernel install <options>
这在使用环境(venv,conda,...)和< options>
让你命名你的内核(参见 - help
)。所以你可以做到
This works when using environments (venv,conda,...) and the <options>
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
现在你在下拉菜单中获取一个名为 py36-test
的内核,以及其他内核。
And now you get a kernel named py36-test
in your dropdown menus, along the other ones.
参见使用Python 2.x和Python 3.x IPython Notebook ,其中包含最新信息。
See Using both Python 2.x and Python 3.x in IPython Notebook which has more recent information.
这篇关于如何将python3内核添加到jupyter(IPython)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!