首页 > 解决方案 > pip 正在安装到 Python 3.7,但我只能访问 Python 3.5

问题描述

我安装了 Python 3.5.7 和一些版本的 Python 3.7。Python 3.7 肯定是通过自制软件安装的,但我可能已经手动安装了 Python 3.5。pip3 正在将包安装到 Python 3.7 的文件夹中,我想使用 Python 3.7,但我不知道如何。命令 python3 使用 Python 3.5,似乎没有 Python 3.7 的文件。

usern$ which python3 
/usr/local/bin/python3
usern$ python3
Python 3.5.7 (default, Apr 18 2019, 12:58:07) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
exit()
usern$ python3 --version
Python 3.5.7
usern$ pip3 --version
pip 19.0.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
usern$ /usr/local/lib/python3.7
-bash: /usr/local/lib/python3.7: is a directory
usern$ /usr/local/bin/python3.7
-bash: /usr/local/bin/python3.7: No such file or directory
usern$ python3.7
-bash: python3.7: command not found

标签: pythonpython-3.xmacospip

解决方案


我实际上只是使用

brew link --overwrite python

这工作得很好。我的 Python 3.5 文件夹已被删除,但 Python 3.7 一切正常。


推荐阅读