欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > python >内容正文

python

jupyter python版本_Ubuntu Desktop 16.04 LTS 下成功配置Jupyter的两个python内核版本(2.7x,3.5x)...

发布时间:2025/4/16 python 62 豆豆
生活随笔 收集整理的这篇文章主要介绍了 jupyter python版本_Ubuntu Desktop 16.04 LTS 下成功配置Jupyter的两个python内核版本(2.7x,3.5x)... 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

Ubuntu  Desktop 16.04 LTS 安装好系统默认就有python两个不同版本(2.7.12和3.5.2)

现在来熟悉一下jupyter的对python这两个不同python版本的内核配置过程:

1.分别下载不同的python内核版本

命令如下:

sudo pip2 install   ipykernel

sudo pip3 install   ipykernel

2.安装不同的python内核版本

命令如下:

sudo python2 -m ipykernel install --user

sudo python3 -m ipykernel install --user

3.配置不同的python内核版本

python2的配置命令:

sudo jupyter kernelspec install /usr/bin/  (python2的路径可通过which python2 命令查看)

python3的配置命令:

sudo jupyter kernelspec install /usr/local/bin/ (python3的路径可通过which python3 命令查看)

4.启动jupyter notebook

sudo jupyter notebook --allow-root

这样就可以看到两个不同版本的python内核版本

注意事项:

1.由于安装jupyter 需要用到~/.cache/pip/http/ 和~/.cache/pip/ 这两个文件目录的root用户私有访问权限,故需要设置权限,否则安装提示失败,

操作命令如下:

sudo chown root ~/.cache/pip/http/

sudo chown root ~/.cache/pip/

2.不要重复使用命令sudo apt-get install ipython 安装ipython,和sudo apt-get install jupyter-core,

否则运行jupyter notebook时会出现“dead kernel”提示系统崩溃,原因待查

已安装ipython的建议先卸载命令如下:

sudo apt-get remove ipython

sudo apt-get remove jupyter-core

sudo apt autoremove

3.建议使用pip方式来安装jupyter,命令如下:

sudo pip install jupyter

配置成功界面:

其它参考资料如下:

pip install 参数

安装指定源pip install -i https://pypi.douban.com/simple package name

升级pip install --upgrade package

jupyter notebook 添加 kernel

这里以在python2环境下的notebook添加python3 kernel为例,

首先,确保python3环境下安装了ipykernel

pip3 install ipykernel

然后在python3的python可执行文件所在目录下执行 python -m ipykernel install

可以添加命令 --name kernelname 为kernel指定名字

查看jupyter notebook kernel

使用命令jupyter kernelspec list可以查看当前的kernel

删除notebook kernel

使用命令jupyter kernelspec remove kernelname

总结

以上是生活随笔为你收集整理的jupyter python版本_Ubuntu Desktop 16.04 LTS 下成功配置Jupyter的两个python内核版本(2.7x,3.5x)...的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。