在Mac上安装了python 3x,但终端仍然显示版本2x

时间:2019-01-12 16:02:35

标签: python-3.x homebrew

我通过Home brew安装了python 3x,该过程成功。

但是当我检查版本时,它显示2倍

这是终端输出

➜  ~ brew install python
Warning: python 3.7.2 is already installed, it's just not linked
You can use `brew link python` to link this version.
➜  ~ brew link python
Linking /usr/local/Cellar/python/3.7.2... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
➜  ~ sudo brew link python
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
➜  ~ python -V 
Python 2.7.10

我认为我需要修改某种路径。做一些魔术然后祈祷...大声笑

任何人都知道如何在我的机器上进行这项工作吗?我是Mac最新电脑

1 个答案:

答案 0 :(得分:1)

首先,通过运行Homebrew Documentation, Troubleshooting page

中的官方命令来解决您的权限问题
cd /usr/local && sudo chown -R $(whoami) bin etc include lib sbin share var opt Cellar Caskroom Frameworks

然后运行brew link python

最后运行echo $PATH,并检查您的/usr/local/bin优先于其他目录。