我知道这个问题已经被问过和回答过很多次了。但是,我仍然无法摆脱这个问题。我在我的Mac上找到了以下信息。
cd /Library/Frameworks/Python.framework/Versions/
Current -> 2.7
3.6
whereispython
/usr/bin/python
which python
/usr/bin/python
which -a python
/usr/bin/python
/usr/bin/python
python
Python 2.7.10 (default)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
即使我按照如下方式编辑
~/.bash_profile
# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
#PYTHONPATH
PYTHONPATH="${PYTHONPATH}:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"
export PYTHONPATH
然后,执行
source ~/.bash-profile
。在重启我的Mac和终端后,当执行which python
时,仍然可以看到/usr/bin/python
而不是指向/Library/../Python2.7
。我卸载了Python并重新安装了
"pip install python"
。此外,我可以看到 Python 安装在 /System/Library/Frameworks/Python.framework/Versions
下。2.6
2.7
2.5 -> 2.6
2.3 -> 2.6
Current -> 2.7
我不确定这里可能缺少了什么。在Mac中如何设置/添加Python路径?请帮助我理解并解决这个问题。你能帮我吗?