我的Jupyter笔记本电脑安装了python 2内核。我不明白为什么。我可能在安装的时候搞砸了。我已经安装了python 3。我怎么能把它加到木星上? 下面是默认的Jupyter使用python3 -m install Jupyter安装并在浏览器中使用Jupyter notebook打开的截图:
当前回答
除了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"
}
}
其他回答
使用Python2获得ipython笔记本(在Windows7上) 用pip install -U Jupyter升级到Jupyter 安装Python3 使用pip3 install Jupyter再次安装Jupyter 使用ipython3 kernelspec install-self安装Python3内核 我终于有两个工作的玉米粒了。
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).
解决方案在官方文档中有详细的说明:https://ipython.readthedocs.org/en/latest/install/kernel_install.html
我尝试了第一种方法。因为我已经安装了ipykernel,简单地运行python3 -m ipykernel install——user就解决了这个问题。
最短最好的解决方案
conda create --name py3-ml python=3.6
conda install ipykernel
source activate py3-ml # or conda activate py3-ml
python -m ipykernel install --user --name py3-ml
如果你使用的是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,您将看到以下截图:
推荐文章
- Python和IPython的区别是什么?
- 如何从终端运行。ipynb Jupyter Notebook ?
- 移除jupyter笔记本上的内核
- 如何使用列的格式字符串显示浮动的熊猫数据帧?
- 使用Python 2。3. Python。IPython Notebook中的x
- 如何加载/编辑/运行/保存文本文件(.py)到IPython笔记本细胞?
- 在安装pip后,“jupyter:命令未找到”
- 在IPython中自动重载模块
- 如何防止谷歌Colab断开连接?
- 熊猫:设定号。Max行数
- 如何在Jupyter Notebook中显示文件中的图像?
- 熊猫操作期间的进度指标
- 修改IPython/Jupyter笔记本工作目录
- 在ipython笔记本中测量单元格执行时间的简单方法
- 插入图像到IPython笔记本markdown