Mac下使用homebrew安装Python3问题

在运行Python项目时需要Python3。
那么就安装Python3,使用homebrew安装,命令如下:

brew install python3

安装成功即可使用。

由于不知道什么时候已经安装了Python3,系统给出一下提示:

Warning: python 3.6.5 is already installed, it's just not linked
You can use `brew link python` to link this version.

Python3.6.5已经存在,但是没有在homebrew中管理,
使用以下命令与homebrew建立管理连接:

brew link python

使用以上命令建立连接,出现以下错误:

Linking /usr/local/Cellar/python/3.6.5... 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

brew不建议你使用系统权限执行以上操作,看来此路不通了。找下大哥google,提供一下方案:

发现/usr/local/下没有路径/usr/local/Frameworks
需要新建该路径,并修改权限

那么就在相应的路径下创建目录,并赋予相应的权限:

sudo mkdir /usr/local/Frameworks

sudo chown $(whoami):admin /usr/local/Frameworks

再次运行关联命令:

brew link python3

Linking /usr/local/Cellar/python/3.6.5... 1 symlinks created

连接成功,O了个K。

猜你喜欢

转载自blog.csdn.net/u012782882/article/details/80539194