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


当前回答

要将特定的python添加到jupyter内核中,首先使用以下命令检查可用的python或python3的路径

$ where python3

假设你有'/usr/local/bin/python3'作为路径之一。要为这个版本的python创建一个名为'name_to_new_kernel'的内核,该内核将显示在jupyter中,

$ /usr/local/bin/python3 -m pip install ipykernel
$ /usr/local/bin/python3 -m ipykernel install --user --name name_to_new_kernel

使用实例检查名称为'name_to_new_kernel'的新内核是否添加到jupyter

jupyter kernelspec list

其他回答

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).

在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内核。

使用Python2获得ipython笔记本(在Windows7上) 用pip install -U Jupyter升级到Jupyter 安装Python3 使用pip3 install Jupyter再次安装Jupyter 使用ipython3 kernelspec install-self安装Python3内核 我终于有两个工作的玉米粒了。

添加内核意味着你想要使用Jupyter Notebook和列表中没有显示的python版本。

简单的方法-使用所需的python版本启动笔记本,假设我安装了python3.7,然后从终端(cmd)使用以下命令来运行笔记本:

python3.7 -m notebook

有时它会使用别名py, py3.7, python来代替python3.7。

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

Pip3安装jupyter