python安装出错记录

安装

1、xcode9.3  macOS 10.13.4

在终端输入: brew install python3

2、安装完报错

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

执行brew doctor

查看出错原因

➜  ~ 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.

python3已安装,no t link

➜  ~ 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

此时安装完成👏

3、中文编码出错的问题

>>> '中文'.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'

>>> 

此处应有👏

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容