我的Jupyter笔记本电脑安装了python 2内核。我不明白为什么。我可能在安装的时候搞砸了。我已经安装了python 3。我怎么能把它加到木星上? 下面是默认的Jupyter使用python3 -m install Jupyter安装并在浏览器中使用Jupyter notebook打开的截图:
当前回答
在Ubuntu 14.04上,我不得不使用之前答案的组合。
首先,安装pip3 安装python-pip3
然后用pip3安装jupyter Pip3安装jupyter
然后使用ipython3安装内核 Ipython3内核安装
其他回答
除了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"
}
}
这个回答解释了如何使用Poetry依赖管理创建Python 3、Jupyter 1和ipykernel 5工作流。诗歌使创建一个虚拟环境的Jupyter笔记本很容易。我强烈建议不要运行python3命令。安装全局依赖项的Python工作流程会让你陷入依赖项地狱。
以下是对干净、可靠的Poetry工作流程的总结:
安装依赖诗词添加熊猫jupyter ipykernel 在虚拟环境中用诗壳打开一个壳 打开Jupyter notebook,访问与Jupyter notebook相关的所有虚拟环境
还有干净的Conda工作流。注意这个帖子里的很多答案——它们会让你走上一条会给你带来很多痛苦和折磨的道路。
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).
以下命令适用于macOS Sierra(10.12.3)
python3 -m pip install ipykernel
python3 -m ipykernel install --user
用 Jupyter内核规格列表 可用内核: python3 /用户/ admin /图书馆/ Jupyter /内核/ python3 python2 / anaconda2 /分享/ jupyter /内核/ python2
确保已经安装了ipykernel,并使用ipython kernel install将kernelspec放到python2的正确位置。然后为Python3安装ipython3内核。现在,无论您使用的是jupyter notebook、ipython notebook还是ipython3 notebook(后两种已弃用),您都应该能够在这两种内核之间进行选择。
注意,如果你想安装一个特定的Python可执行文件,你可以使用以下技巧:
path/to/python -m ipykernel install <options>
当使用环境(venv,conda,…)和<选项>让你命名你的内核时,这是有效的(参见——help)。所以你可以
conda create -n py36-test python=3.6
source activate py36-test
python -m ipykernel install --name py36-test
source deactivate
现在,在下拉菜单中可以看到名为py36-test的内核和其他内核。
参见使用Python 2。3. Python。IPython Notebook中的最新信息。
推荐文章
- 检查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笔记本细胞?
- 在安装pip后,“jupyter:命令未找到”
- 在IPython中自动重载模块