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


当前回答

用于当前的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

其他回答

以下命令适用于macOS Sierra(10.12.3)

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

用 Jupyter内核规格列表 可用内核: python3 /用户/ admin /图书馆/ Jupyter /内核/ python3 python2 / anaconda2 /分享/ jupyter /内核/ python2

在Ubuntu 14.04上,我不得不使用之前答案的组合。

首先,安装pip3 安装python-pip3

然后用pip3安装jupyter Pip3安装jupyter

然后使用ipython3安装内核 Ipython3内核安装

如果你使用的是anaconda发行版,这对我来说是有效的(在macintosh上):

$ conda create -n py3k python=3 anaconda

$ source activate py3k

$ ipython kernelspec install-self

最后一个命令需要注意:

(py3k)Monas-MacBook-Pro:cs799 mona$ ipython kernelspec install-self
[TerminalIPythonApp] WARNING | Subcommand `ipython kernelspec` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter kernelspec` in the future
[InstallNativeKernelSpec] WARNING | `jupyter kernelspec install-self` is DEPRECATED as of 4.0. You probably want `ipython kernel install` to install the IPython kernelspec.
[InstallNativeKernelSpec] Installed kernelspec python3 in /usr/local/share/jupyter/kernels/python3
(py3k)Monas-MacBook-Pro:cs799 mona$ ipython kernel install 
Installed kernelspec python3 in /usr/local/share/jupyter/kernels/python3

按照上述步骤在OSX Yosemite中进行测试,并输入jupter notebook并在浏览器中创建一个新的notebook,您将看到以下截图:

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

Pip3安装jupyter

这对我在Ubuntu 16.04上是有效的:

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

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

参考文档: Python 2和3的内核。安装IPython内核- IPython Docs。