如何将python3内核添加到jupyter(IPython)

2024-04-26 03:12:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我的Jupyter笔记本安装了python 2内核。我不明白为什么。我在安装的时候可能把事情弄糟了。我已经安装了python 3。如何将其添加到Jupyter? 下面是一个屏幕截图,显示了在浏览器中使用jupyter notebook打开的默认Jupyterpython3 -m install jupyter所包含的内容: enter image description here


Tags: install内容屏幕浏览器笔记本jupyter事情内核
3条回答

确保安装了ipykernel,并使用ipython kernel install将kernelspec放在python2的正确位置。然后是Python3的ipython3 kernel install。现在,您应该能够在两个内核之间进行选择,而不管您使用的是jupyter notebookipython notebook还是ipython3 notebook(后两个内核已弃用)。

注意,如果要为特定的Python可执行文件安装,可以使用以下技巧:

path/to/python -m ipykernel install <options>

当使用环境(venv,conda,…)和<options>让您命名您的内核(请参见--help)时,这是有效的。所以你可以

conda create -n py36-test python=3.6
source activate py36-test
python -m ipykernel install --name py36-test
source deactivate

现在,您在下拉菜单中获得了一个名为py36-test的内核以及其他的内核。

请参阅Using both Python 2.x and Python 3.x in IPython Notebook,其中包含最新信息。

  1. 有带Python2的ipython笔记本(在Windows7上)
  2. 使用pip install -U jupyter升级到Jupyter
  3. 安装Python3
  4. 使用pip3 install jupyter重新安装Jupyter
  5. 使用ipython3 kernelspec install-self安装Python3内核
  6. 我终于有了两颗工作核。

great results

这对我在Ubuntu16.04上很有效:

python2 -m pip install ipykernel
python2 -m ipykernel install --user

python3 -m pip install ipykernel
python3 -m ipykernel install --user

参考文档:
Kernels for Python 2 and 3。安装IPython内核-IPython文档。

相关问题 更多 >