C:\Users\用户>pip install NumPy
Collecting NumPy
Exception:
Traceback (most recent call last):
File “c:\python27\lib\site-packages\pip\basecommand.py”, line 215, in main
status = self.run(options, args)
File “c:\python27\lib\site-packages\pip\commands\install.py”, line 324, in run
requirement_set.prepare_files(finder)
File “c:\python27\lib\site-packages\pip\req\req_set.py”, line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File “c:\python27\lib\site-packages\pip\req\req_set.py”, line 620, in _prepare_file
session=self.session, hashes=hashes)
File “c:\python27\lib\site-packages\pip\download.py”, line 821, in unpack_url
hashes=hashes
File “c:\python27\lib\site-packages\pip\download.py”, line 659, in unpack_http_url
hashes)
File “c:\python27\lib\site-packages\pip\download.py”, line 880, in _download_http_url
file_path = os.path.join(temp_dir, filename)
File “c:\python27\lib\ntpath.py”, line 85, in join
result_path = result_path + p_path
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xd3 in position 7: ordinal not in range(128)
原因是pip安装Python包会加载我的用户目录,我的用户目录恰好是中文的,ascii不能编码。
解决办法是:
python目录 Python27\Lib\site-packages 建一个文件sitecustomize.py
内容写:
import sys
sys.setdefaultencoding('gbk')
python会自动运行这个文件。
---------------------
作者:多串君_Kwane
来源:CSDN
原文:https://blog.csdn.net/u013567842/article/details/68955214
版权声明:本文为博主原创文章,转载请附上博文链接!