[英]pip3 points to python 3.8 and jupyter notebook points to python 3.9. Having trouble syncing the two
which pip3:哪个pip3:
/Library/Frameworks/Python.framework/Versions/3.8/bin/pip3
python version in notebook: python 笔记本中的版本:
import platform
print(platform.python_version())
3.9.2
I want my jupyter notebook to run on python 3.8.我希望我的 jupyter 笔记本在 python 3.8 上运行。
NOTE: I'm intentionally avoiding conda for this exercise.注意:我故意在这个练习中避免使用 conda。
Jupyter is installed into a particular Python environment like any other Python module. Jupyter 安装到特定的 Python 环境中,就像任何其他 Python 模块一样。 If Jupyter is running under Python 3.9, then you're running the version of it that was installed by the pip
in Python 3.9.如果 Jupyter 在 Python 3.9 下运行,那么您正在运行由pip
中的 pip 安装的版本。 It might be installed in the base 3.9 implementation, or it could be installed in a virtual environment that is based on Python 3.9.它可能安装在基本 3.9 实现中,也可能安装在基于 Python 3.9 的虚拟环境中。
If you want a Jupyter that is running under Python 3.8, then you need to run the version of it that is installed under Python 3.8 or a virtual environment based on 3.8.如果您想要在 Python 3.8 下运行的 Jupyter,那么您需要运行安装在 Python 3.8 或基于 3.8 的虚拟环境下的版本。 If no such version exists, then you need to install it using Python 3.8 pip.如果不存在这样的版本,则需要使用 Python 3.8 pip 安装它。 Once installed, you need to run that version of it.安装后,您需要运行该版本。 You can always do that by specifying the full path to the appropriate jupyter
binary.您始终可以通过指定适当的jupyter
二进制文件的完整路径来做到这一点。 But that is, of course, not ideal...但这当然不理想……
Which version you get when you run just jupyter
is a function of your PATH and/or any Python package manager you might be running.仅运行jupyter
时获得的版本是 PATH 的 function 和/或您可能正在运行的任何 Python package 管理器。 I use pyenv
, and that tool will set it up so that for the Python version I've chosen to be the current global version, that version's (or virtual environment's) bin
directory becomes the first Python bin
directory in my PATH.我使用pyenv
,该工具将对其进行设置,以便对于我选择作为当前全局版本的 Python 版本,该版本(或虚拟环境)的bin
目录成为我的 PATH 中的第一个 Python bin
目录。 So if I type jupyter
, I always run the version that is installed in what pyenv
has made the current global Python environment.因此,如果我键入jupyter
,我总是运行安装在pyenv
已使当前全局 Python 环境中的版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.