简体   繁体   English

jupyter notebook/lab 终端 python 版本

[英]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/pythonpython -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/pythonpython -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.

相关问题 在jupyter笔记本中没有python终端 - No python terminal in jupyter notebook “未找到导入 tensorflow 模块”仅在 jupyter 笔记本上,但不在 jupyter 实验室或终端上 - "Importing tensorflow module not found" Only on jupyter notebook but not jupyter lab or terminal 获取当前的 jupyter-lab 笔记本名称 [适用于 Jupyter-lab 版本 2.1 和 3.0.1 以及笔记本版本 >6.0.3) - Get current jupyter-lab notebook name [for Jupyter-lab version 2.1 and 3.0.1 and notebook version >6.0.3) 不同的 python 版本 Jupyter Notebook linux 终端,在 jupyter 中找不到模块,但能够在终端中找到 - Different python version Jupyter Notebook linux terminal, can't find module in jupyter, but able to do that in terminal 尝试从终端打开 Jupyter Notebook 不断收到 zsh 错误:找不到命令:jupyter:Python 版本:2.7.16 - Trying to Open Jupyter Notebook from Terminal constantly getting error of zsh: command not found: jupyter: Python Version: 2.7.16 Python版本和Jupyter Notebook的问题 - Problem with Python Version And Jupyter Notebook 在 jupyter 笔记本中更改 python 版本 - change python version in jupyter notebook Jupyter Notebook (myenv: 'conda') 中的 Python 版本不同的终端版本,我想更新 - Python version in Jupyter Notebook (myenv: 'conda') different terminal version and I want to update 如何在Jupyter Notebook和终端之间匹配python版本的版本? 3.6.5至3.7 - How do I match version of python version between jupyter notebook and terminal? 3.6.5 to 3.7 Python:从Jupyter Notebook执行终端命令 - Python: executing a terminal command from jupyter notebook
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM