Python错误集锦:pip安装模块时提示“UnicodeDecodeError: ‘utf-8’ codec can’t decode

原文链接:http://www.juzicode.com/archives/3857

错误提示:

pip安装模块时提示“UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xa1 in position 96: invalid start byte”

D:\dev\Python\Python36-32\Scripts>pip install thrift
Collecting thrift
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/97/1e/3284d19d7be99305eda145b8aa46b0c33244e4a496ec66440dac19f8274d/thrift-0.13.0.tar.gz (59kB)
    100% |████████████████████████████████| 61kB 90kB/s
Requirement already satisfied: six>=1.7.2 in d:\dev\python\python36-32\lib\site-packages (from thrift)
Installing collected packages: thrift
  Running setup.py install for thrift ... error
Exception:
Traceback (most recent call last):
  File "d:\dev\python\python36-32\lib\site-packages\pip\compat\__init__.py", line 73, in console_to_str
    return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 96: invalid start byte

During handling of the above exception, another exception occurred:

错误原因:

1、pip版本太低, 某些模块的安装需要更高版本的pip。

D:\dev\Python\Python36-32\Scripts>pip -V
pip 9.0.3 from d:\dev\python\python36-32\lib\site-packages (python 3.6)

解决方法:

1、升级pip版本:

D:\dev\Python\Python36-32>python -m pip install --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/packages/fe/ef/60d7ba03b5c442309ef42e7d69959f73aacccd0d86008362a681c4698e83/pip-21.0.1-py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 9.0.3
    Uninstalling pip-9.0.3:
      Successfully uninstalled pip-9.0.3
Successfully installed pip-21.0.1

D:\dev\Python\Python36-32\Scripts>pip -V
pip 21.0.1 from d:\dev\python\python36-32\lib\site-packages\pip (python 3.6)

2、安装模块:

D:\dev\Python\Python36-32\Scripts>pip install thrift
Collecting thrift
  Using cached thrift-0.13.0.tar.gz (59 kB)
Requirement already satisfied: six>=1.7.2 in d:\dev\python\python36-32\lib\site-packages (from thrift) (1.11.0)
Using legacy 'setup.py install' for thrift, since package 'wheel' is not installed.
Installing collected packages: thrift
    Running setup.py install for thrift ... done
Successfully installed thrift-0.13.0

扩展内容:

  1. Python进阶教程m1–模块(module)


如果本文还没有完全解决你的疑惑,你也可以在微信公众号“桔子code”后台给我留言,欢迎一起探讨交流。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注