事情:用pip爲Python3安裝scrapy時,執行以下命令
python3 -m pip install scrapy -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
報錯,一切指向一個關鍵詞“gcc”
error: command 'gcc' failed with exit status 1
試了以下的辦法:
在終端中執行(前提是已經按照了homebrew)
brew search gcc5
結果提示
Error: You have not agreed to the Xcode license. Please resolve this by running:
sudo xcodebuild -license accept
嗯?要同意xcode的用戶協議?於是把電腦上的xcode打開,果然先要先接受用戶協議才能用,一點接受,然後再嘗試用pip按照。然後就順利成功了,根本不需要按網絡上各種教程去安裝或者升級gcc。如果大家在Mac 下pip遇到gcc的錯誤,不妨嘗試打開你們的xcode,看看是不是用戶協議的問題。