我的Jupyter笔记本电脑安装了python 2内核。我不明白为什么。我可能在安装的时候搞砸了。我已经安装了python 3。我怎么能把它加到木星上? 下面是默认的Jupyter使用python3 -m install Jupyter安装并在浏览器中使用Jupyter notebook打开的截图:
当前回答
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).
其他回答
要将特定的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
当你使用conda管理你的python envs时,遵循以下两个步骤:
激活py3(在Windows上或在Linux上激活py3) Conda install notebook ipykernel或者直接使用Conda install jupyter
我很确定你要做的就是逃跑
Pip3安装jupyter
在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之外,我还设法安装了Python3内核。我是这样做的:
在木星上打开一个新的笔记本 复制并运行这里的两个单元格:Enable-Python-3-kernel
最新的工作链接可以在这里找到。
实际代码为:
! mkdir -p ~/.ipython/kernels/python3
%%file ~/.ipython/kernels/python3/kernel.json
{
"display_name": "IPython (Python 3)",
"language": "python",
"argv": [
"python3",
"-c", "from IPython.kernel.zmq.kernelapp import main; main()",
"-f", "{connection_file}"
],
"codemirror_mode": {
"version": 2,
"name": "ipython"
}
}
推荐文章
- 当试图运行Python脚本时,“ImportError:没有命名模块”
- 如何阅读一个。xlsx文件使用熊猫库在iPython?
- 检查pandas数据框架索引中是否存在值
- Ipython笔记本清除单元格输出代码
- tqdm在Jupyter笔记本重复打印新的进度条
- 折叠单元在jupyter笔记本
- 如何知道哪个Python在Jupyter笔记本上运行?
- 使用Python 3在Jupyter Notebook中使用相对导入从位于另一个目录中的模块导入本地函数
- 如何嵌入HTML到IPython输出?
- Python和IPython的区别是什么?
- 如何从终端运行。ipynb Jupyter Notebook ?
- 移除jupyter笔记本上的内核
- 如何使用列的格式字符串显示浮动的熊猫数据帧?
- 使用Python 2。3. Python。IPython Notebook中的x
- 如何加载/编辑/运行/保存文本文件(.py)到IPython笔记本细胞?