1. 程式人生 > >Mac下使用homebrew安裝Python3問題

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。