【发布时间】:2021-05-06 07:21:56
【问题描述】:
我正在尝试在 macOS Big Sur 上将 Python 3.7 升级到 3.9。我还试图避免丢失安装在 Python 3.7 上的软件包并在 Python 3.9 上重新安装它们
我尝试过使用
brew install python3
brew update && brew upgrade python
产生了
Already up-to-date.
Warning: python3 3.9.1_7 already installed
但是,当我运行 python3 --version 时,它会产生 Python 3.7.0
这是别名的问题吗?有没有办法卸载 Python 3.7 并保留 Python 3.9?
运行brew link python3 产生
Linking /usr/local/Cellar/python@3.9/3.9.1_7...
Error: Could not symlink bin/2to3
Target /usr/local/bin/2to3
already exists. You may want to remove it:
rm '/usr/local/bin/2to3'
To force the link and overwrite all conflicting files:
brew link --overwrite python@3.9
To list all files that would be deleted:
brew link --overwrite --dry-run python@3.9
【问题讨论】:
-
听起来你的
PATH是错误的。type -a python3的输出是什么?你的PATH是什么样的,你是从你的shell 的启动文件中操作它吗?请edit提供这些详细信息。 -
没有办法让所有已安装的软件包都随身携带。
pip的体系结构要求您将所需的包安装到所需的 Python 版本中。您可以在旧 Python 中运行pip freeze,然后(可能手动修剪列表和)pip install相同的包到新版本中。
标签: python