在安装lunarsolarconverter第三方库时提示:
File "<string>", line 1, in <module> File "C:\Users\Administrator\AppData\Local\Temp\pip-install-wr4z978d\Lunar SolarConverter\setup.py", line 15, in <module> long_description = f.read() UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 65: illeg al multibyte sequence ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check th e logs for full command output.
根据提示信息,应该是文件读取中涉及到了中文
下载了LunarSolarConverter-1.1.0.tar.gz到本地并解压,查看其中的setup.py文件,其中14,15行:
with open('README.rst') as f: long_description = f.read()
问题应该出在了14行 open 这个函数,作者应该在其后增加 encoding='UTF-8' ,确保数据读取无误。
既然定位到了问题,就修改验证下吧。修改后的代码:
with open('README.rst', encoding='UTF-8') as f: long_description = f.read()
因为修改了文件内容,所以我们只好进行本地化安装,代码: python setup.py install
运行结果:
Installed f:\python38\lib\site-packages\lunarsolarconverter-1.1.0-py3.8.egg Processing dependencies for LunarSolarConverter==1.1.0 Finished processing dependencies for LunarSolarConverter==1.1.0
问题解决了,收工。