我的Jupyter笔记本电脑安装了python 2内核。我不明白为什么。我可能在安装的时候搞砸了。我已经安装了python 3。我怎么能把它加到木星上? 下面是默认的Jupyter使用python3 -m install Jupyter安装并在浏览器中使用Jupyter notebook打开的截图:


当前回答

解决方案在官方文档中有详细的说明:https://ipython.readthedocs.org/en/latest/install/kernel_install.html

我尝试了第一种方法。因为我已经安装了ipykernel,简单地运行python3 -m ipykernel install——user就解决了这个问题。

其他回答

我也面临着同样的问题。每当我使用以下命令启动jupyter notebook时,我都不会看到创建一个新的Python 3 notebook的选项。

我通过运行以下命令解决了这个问题。

pip install notebook

之后,我开始笔记本与相同的命令之前

jupyter notebook

我能够看到我的主目录并创建新的python3笔记本。

用于当前的Python启动器

如果您安装了Py3,但默认为py2

py -3 -m pip install ipykernel
py -3 -m ipykernel install --user

如果您安装了Py2,但默认为py3

py -2 -m pip install ipykernel
py -2 -m ipykernel install --user

在ElementaryOS Freya(基于Ubuntu 14.04)上,其他答案都没有立即对我起作用;我得到了

[TerminalIPythonApp]警告|文件不存在:'kernelspec'

quickbug在Matt的回答中描述的错误。我首先要做的是:

Sudo apt-get安装pip3

安装ipython[所有]

这时你就可以运行Matt建议的命令了;即:ipython kernelspec install-self和ipython3 kernelspec install-self

现在,当我启动ipython notebook,然后打开一个notebook时,我能够从kernel菜单中选择Python 3内核。

我很确定你要做的就是逃跑

Pip3安装jupyter

Here's a Windows/non command line method I found, which worked for me: Find the folder where the kernel files are stored (on my machine - C:\ProgramData\jupyter\kernels - note that ProgramData is a hidden folder), create a copy of the existing kernel's folder, change the name and edit the json file within to point to the new kernel's directory. In this json you can also edit the kernel name that is displayed in ipython (e.g. instead of just python 2 you can specify 2.7.9 if you need to further distinguish for some reason).