python - macOS BigSur 上 python 版本的问题

标签 python macos python-2.7 macos-big-sur

我对 python 版本有疑问。我直接从站点 3.9.0 下载并安装了最新版本的 python,但是当我使用 python --version 命令从终端检查版本时,安装了 2.7.16 并安装了 PIP 包管理器,我得到了这个回应:

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting pip
Downloading pip-20.2.4-py2.py3-none-any.whl (1.5 MB)|████████████████████████████████| 1.5 MB 1.7 MB/s 
Installing collected packages: pip

WARNING: The scripts pip, pip2 and pip2.7 are installed in '/Users/user/Library/Python/2.7/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.2.4

最佳答案

[编辑](感谢@JohnVargo)
Big Sur 默认使用 zsh,因此您必须修改 .zprofile i/o .bash_profile。 ...除非您将默认设置更改为使用 bash,否则请执行以下操作:
[/编辑]


如果您想使用 python 从命令行启动 python3,您可以转到您的主目录并编辑您的 ~/.bash_profile 添加以下行:

在终端输入 $ which python 这将返回系统 python2 解释器的路径;让我们称之为 path_to_p2

在终端输入 $ which python3 这将返回系统 python3 解释器的路径;让我们称之为 path_to_p3

export PATH=path_to_p3:$PATH
alias python3=path_to_p3
alias python=path_to_p3

export PATH=path_to_p2:$PATH
alias python2=path_to_p2

保存,重新启动终端;您现在可以使用 pythonpython3 启动 python3,并使用 python2 启动 python2 >

关于python - macOS BigSur 上 python 版本的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64935752/

相关文章:

python-2.7 - logger.warning ("MSVC is not supported") 在 Windows 10 上安装 pystan 时出错

python 添加缺失的日期并更新相应的列表

macos - 与 Xcode 一起安装 LLVM 库

python - 在 python 属性上重载运算符

python - Pandas dataframe 隔离关键字下方的行

python - 使用 nltk 时。在 nltk 函数之前

c - 在 mac os 10.11 上运行 valgrind 会产生错误

macos - 创建不需要管理员权限的 MacOS .pkg 安装程序

python - 工作线程完成后从主线程更新 Tkinter 小部件

python - 为什么设置自动解包范围,但列表不?如何使用它?