[英]jupyter notebook/lab terminal python version
How do I change the python version of jupyter lab's terminal?如何更改 jupyter 实验室终端的 python 版本?
For instance, in the terminal of jupyter lab, which python
would return /usr/bin/python
, and python -V
--> Python 2.7.10
;例如,在 jupyter lab 的终端中,
which python
会返回/usr/bin/python
和python -V
--> Python 2.7.10
;
But in my laptop's terminal, which python
--> /Users/name/anaconda3/bin/python
, python -V
--> Python 3.7.5
.但是在我笔记本电脑的终端中,
which python
--> /Users/name/anaconda3/bin/python
, python -V
--> Python 3.7.5
。
Thanks!谢谢!
Install Jupyter using that Python and uninstall from Python 2 (because Python 2 is end of life and you shouldn't be installing things into the System python anyway)使用该 Python 安装 Jupyter 并从 Python 2 卸载(因为 Python 2 已经结束,无论如何你都不应该将东西安装到系统 python 中)
/Users/name/anaconda3/bin/python -m pip install jupyter
Or define a new kernel for Jupyter that uses that Python path (after installing ipython
into it)或者为使用该 Python 路径的 Jupyter 定义一个新内核(在将
ipython
安装到其中之后)
{
"argv": [
"/Users/name/anaconda3/bin/python",
"-m",
"ipykernel",
"-f",
"{connection_file}"
],
"display_name": "Anaconda 3",
"language": "python"
}
Bonus : Learn pyenv
奖励:学习
pyenv
Here's what I did to resolve this.这是我为解决此问题所做的工作。 I reset the PATH variable to be the default at the top of my .zshrc file (on a Mac) before anything else touches PATH.
我将 PATH 变量重置为我的 .zshrc 文件顶部的默认值(在 Mac 上),然后其他任何东西都会触及 PATH。 That is, I have included these two lines at the top:
也就是说,我在顶部包含了这两行:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
export PATH
After restarting Jupyter Lab, doing which python
now gives me the correct python version instead of 2.7 like it was before.重新启动 Jupyter Lab 后,执行
which python
现在为我提供了正确的 python 版本,而不是像以前那样的 2.7。 According to a comment here , the PATH variable is flipped so it causes issues about which Python to source first.根据这里的评论,PATH 变量被翻转,因此它会导致关于首先使用哪个 Python 的问题。 By enforcing the default PATH before Anaconda gets to it, it will ensure that Anaconda's Python gets sourced first in the Jupyter Lab terminal.
通过在 Anaconda 到达之前强制执行默认 PATH,它将确保 Anaconda 的 Python 首先在 Jupyter Lab 终端中获取。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.