当需要生成某个项目所需要的包以及相应的版本,可以先cd到项目目录,然后输入:
pipreqs ./
报编码错误,如下:
Traceback (most recent call last): File "f:usersasusanaconda3librunpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "f:usersasusanaconda3librunpy.py", line 85, in _run_code exec(code, run_globals) File "F:UsersasusAnaconda3scriptspipreqs.exe__main__.py", line 7, inFile "f:usersasusanaconda3libsite-packagespipreqspipreqs.py", line 470, in main init(args) File "f:usersasusanaconda3libsite-packagespipreqspipreqs.py", line 409, in init follow_links=follow_links) File "f:usersasusanaconda3libsite-packagespipreqspipreqs.py", line 122, in get_all_imports contents = f.read() File "f:usersasusanaconda3libcodecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 570: invalid start byte
找到pipreqs.py第122行,修改编码格式为ISO-8859-1即可。
with open_func(file_name, "r", encoding='ISO-8859-1') as f: contents = f.read()
尝试了很多编码格式,比如gbk,gb18030等等还是报错,直到用ISO-8859-1才行。具体原因是因为decode的参数设置过于严格,设置为igonre,但是也没找到decode函数在哪里更改。后续找到了再来更改吧。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)