在使用pipreqs检查python项目依赖时遇到的问题
先安装 pip install pipreqs
首先执行E:codeHainanRubberMeteorwebserver> pipreqs --use-local ./
报错:UnicodeDecodeError: "gbk" codec can"t decode byte 0xbf in position 2: illegal multibyte sequence
需要上--encoding=utf8 如下
E:codeHainanRubberMeteorwebserver> pipreqs --use-local --encoding=utf8 --force .
如果已经存在requirements.txt,需要加上 --force 覆盖之
遇到代码开头结尾编码问题
ERROR: Failed on file: ./app.py File "d:python37libunpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:python37libunpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:Python37Scriptspipreqs.exe\__main__.py", line 7, in <module>
File "d:python37libsite-packagespipreqspipreqs.py", line 470, in main
init(args)
File "d:python37libsite-packagespipreqspipreqs.py", line 409, in init
follow_links=follow_links)
File "d:python37libsite-packagespipreqspipreqs.py", line 138, in get_all_imports
raise exc
File "d:python37libsite-packagespipreqspipreqs.py", line 124, in get_all_imports
tree = ast.parse(contents)
File "d:python37libast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
# -*- coding: utf-8 -*-
^
SyntaxError: invalid character in identifier
重新创建一个代码文件,把代码拷贝进去,错误消失,现在也不知道是何问题
附代码:
以上是 在使用pipreqs检查python项目依赖时遇到的问题 的全部内容, 来源链接: utcz.com/z/517459.html