PyMySQL安装问题解决办法-UnicodeDecodeError:gbk codec cannot decode byte 0xaf
依据报错信息,找到site.py 对应文件,分析问题所在行,可能原因是遍历函数无法解码 f 所致,根据提示的编码解码问题,搜索site.py文件中编码encoding值,如175行所示,之前值是locale,修改为utf-8即解决问题。
try:
# locale encoding is not ideal especially on Windows. But we have used
# it for a long time. setuptools uses the locale encoding too.
f = io.TextIOWrapper(io.open_code(fullname), encoding="utf-8")
except OSError:
return
with f:
for n, line in enumerate(f):
if line.startswith("#"):
continue
关于locale值,文档注释解释说,使用locale值,在windows下是不理想的,但是安装工具也使用locale编码,我们已使用很长时间了。
locale encoding is not ideal especially on Windows. But we have used
# it for a long time. setuptools uses the locale encoding too.
![PyMySQL安装问题解决办法-UnicodeDecodeError](https://img-blog.csdnimg.cn/158a4edcd7fd4d49a1a5c45f349fb756.png#pic_center