在命令行执行任何pip命令都报错:
C:Usershyang0>pip --version Traceback (most recent call last): File "c:python3lib unpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:python3lib unpy.py", line 85, in _run_code exec(code, run_globals) File "C:python3Scriptspip.exe\__main__.py", line 9, in <module> File "c:python3libsite-packagespip\__init__.py", line 219, in main cmd_name, cmd_args = parseopts(args) File "c:python3libsite-packagespip\__init__.py", line 159, in parseopts parser = create_main_parser() File "c:python3libsite-packagespip\__init__.py", line 137, in create_main_parser parser = ConfigOptionParser(**parser_kw) File "c:python3libsite-packagespipaseparser.py", line 148, in __init__ self.config.read(self.files) File "c:python3libconfigparser.py", line 697, in read self._read(fp, filename) File "c:python3libconfigparser.py", line 1015, in _read for lineno, line in enumerate(fp, start=1): UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 67: illegal multibyte sequence
在segmentfault][1]上找到问题原因,之前配置过 %APPDATA%pippip.ini 文件,编码为utf-8。估计要用原生的cp939才行,将pip.ini删掉后重新执行pip命令恢复正常。
C:Usershyang0>pip list DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning. pip (9.0.1) setuptools (28.8.0) You are using pip version 9.0.1, however version 10.0.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command. C:Usershyang0>python -m pip install --upgrade pip Collecting pip Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 876kB/s Installing collected packages: pip Found existing installation: pip 9.0.1 Uninstalling pip-9.0.1: Successfully uninstalled pip-9.0.1 Successfully installed pip-10.0.1 C:Usershyang0>
[1]: https://segmentfault.com/q/1010000012807558/a-1020000012989591 "pip gbk decode"