为了这个问题我在网上搜索了一段时间,目前我所做的是
在自制软件中安装了python32
更改了我的 .bash_profile 并在其中添加了以下行:
export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH
但是当我关闭终端并重新开始时,我输入'which python',它仍然打印:
/usr/bin/python
然后输入 'python --version' 仍然得到:
Python 2.7.2
我还尝试了以下说明:
brew link --overwrite python
或尝试通过运行以下指令来删除由 homebrew 安装的 python:
brew remove python
但是以上两条指令都会导致这个错误:
Error: No such keg: /usr/local/Cellar/python
谁能帮忙,谢谢
最佳答案
brew install python
或 brew info python
输出提及:
Unversioned symlinks
python
,python-config
,pip
etc. pointing topython3
,python3-config
,pip3
etc., respectively, have been installed into /opt/homebrew/opt/python@3.9/libexec/bin
这样跑
% echo 'export PATH=/opt/homebrew/opt/python@3.9/libexec/bin:$PATH' >> ~/.zprofile
% source ~/.zprofile
# For bash use ~/.bash_profile.
为您提供 Homebrew 创建的符号链接(symbolic link) - python=python3、pip=pip3 等
% python --version
Python 3.9.10
% pip --version
pip 21.3.1 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
关于python - 如何让 Mac OS 使用 Homebrew 安装的 python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18419500/