我在链接python3并将python3设置为默认python时遇到问题。
MacOS 10.13.6
这就是我所做的:
$ python --version
Python 2.7.15
$ python3 --version
Python 3.7.0
$ xcode-select --version
xcode-select version 2349.
$ brew install python
...
Python has been installed as
/usr/local/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
/usr/local/opt/python/libexec/bin
...
它不起作用。 python
仍为2。*
$ python --version
Python 2.7.15
$ python3 --version
Python 3.7.0
$ pip --version
pip 10.0.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
$ pip3 --version
pip 18.0 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
我做到了:
$ brew link python3
Warning: Already linked: /usr/local/Cellar/python/3.7.0
To relink: brew unlink python && brew link python
$ python --version
Python 2.7.15
$ brew install python3
...
Warning: python 3.7.0 is already installed and up-to-date
To reinstall 3.7.0, run `brew reinstall python`
$ brew reinstall python
也不起作用
$ brew link python3
Warning: Already linked: /usr/local/Cellar/python/3.7.0
To relink: brew unlink python && brew link python
$ python --version
Python 2.7.15
$ python3 --version
Python 3.7.0
答案 0 :(得分:2)
我假设您的意思是您要命令python
启动 Python3 解释器,并希望pip
启动pip3
。
提示在消息中
未版本化的符号链接
python
,python-config
,pip
等指向python3
,python3-config
,pip3
等已分别安装到 / usr / local / opt / python / libexec / bin
这意味着... ”如果您希望命令python
启动python3
,而pip
启动pip3
,则需要输入{{1 }}放在您的PATH开头。”
因此,在您的登录脚本(/usr/local/opt/python/libexec/bin
或类似名称)中,您需要输入:
$HOME/.profile
然后注销并重新登录以使其生效。
顺便说一句,export PATH=/usr/local/opt/python/libexec/bin:$PATH
仅意味着... “在brew link python3
中创建一个指向/usr/local/bin/python3
的符号链接” 。
您可以通过以下方式查看该链接及其指向的位置:
/usr/local/Cellar/python/3.7.0/python3