最近写flask要用到bleach,bleach有一个依赖库html5lib,需要更高的setuptools 版本。pip install 命令报错:UnicodeError:'utf-8' codec can't decode byte 0xc7 in position 6135:invalid continuation byte又在网上找了好久,又说什么版本不合适的,还有老生常谈的直接拉出一篇长文开始给你讲encode和decode的区别。。无语,最后还是自己动手解决了。
按照错误提示:
找到文件:C:\Users\青霖\testflask\venv\Lib\site-packages\pip\_vendor\pkg_resources\__init__.py 对应的代码块:
else:
def get_metadata(self, name):
if not self.egg_info:
return ""
return self._get(self._fn(self.egg_info, name)).decode("utf-8")
尝试把decode("utf-8")换成decode("gbk"),问题解决了:
唉,文字编码的问题总是那么诡异!
希望能帮到你!