在安装pip 9.0.1期间使用python 2.7.5在Red Hat 4.8上使用命令 pip install --upgrade pip 我收到这个错误:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 272, in run
with self._build_session(options) as session:
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 72, in _build_session
insecure_hosts=options.trusted_hosts,
File "/usr/lib/python2.7/site-packages/pip/download.py", line 329, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/lib/python2.7/site-packages/pip/download.py", line 93, in user_agent
from pip._vendor import distro
File "/usr/lib/python2.7/site-packages/pip/_vendor/distro.py", line 1050, in <module>
_distro = LinuxDistribution()
File "/usr/lib/python2.7/site-packages/pip/_vendor/distro.py", line 594, in __init__
if include_lsb else {}
File "/usr/lib/python2.7/site-packages/pip/_vendor/distro.py", line 922, in _get_lsb_release_info
stdout, stderr = stdout.decode('utf-8'), stderr.decode('utf-8')
File "/usr/lib64/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xea in position 22: invalid continuation byte
pip的某些命令可以正常工作,例如 pip list 显示信息,但是 最后它还显示了上面的回溯。
pip install pandas 根本不起作用。
pip --version 命令显示:
pip 9.0.1 from /usr/lib/python2.7/site-packages (python 2.7)
此外,我无法使用命令安装以前的版本:
pip install pip=8.1.1
这是否意味着安装失败或我只是需要 做一些改变,使pip正常工作? (顺便说一下,所有语言环境都是cp1251)
答案 0 :(得分:0)
我认为,您需要更改系统的默认编码, 此代码允许您将其更改为“ISO-8859-1”:
import sys
reload(sys)
sys.setdefaultencoding('ISO-8859-1')