安裝
1、xcode9.3 ?macOS 10.13.4
在終端輸入:?brew install python3
2、安裝完報(bào)錯(cuò)
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/Frameworks
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
執(zhí)行brew doctor
查看出錯(cuò)原因
?? ~ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
? python
Warning: Your Xcode (9.2) is outdated.
Please update to Xcode 9.3 (or delete it).
Xcode can be updated from the App Store.
Warning: Some installed formulae are missing dependencies.
You should `brew install` the missing dependencies:
? brew install python@2
Run `brew missing` for more details.

?? ~ sudo mkdir /usr/local/Frameworks
Password:
mkdir: /usr/local/Frameworks: File exists
?? ~ sudo chown $(whoami):admin /usr/local/Frameworks
?? ~brew link python3? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Linking /usr/local/Cellar/python/3.6.5... 1 symlinks created
此時(shí)安裝完成??
3、中文編碼出錯(cuò)的問題
>>> '中文'.encode('utf-8')
Traceback (most recent call last):
? File "", line 1, in
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)
解決辦法:
>>> import sys
>>> reload(sys)
>>> sys.setdefaultencoding('utf8')
>>> '中文'.encode('utf-8')
'\xe4\xb8\xad\xe6\x96\x87'
>>>?
此處應(yīng)有??