pipreqs生成python项目依赖清单
环境
pip install pipreqs
在项目目录下
pipreqs ./
报错:
Traceback (most recent call last):
File “d:pythonlibrunpy.py”, line 193, in _run_module_as_main
“main”, mod_spec)
File “d:pythonlibrunpy.py”, line 85, in run_code
exec(code, run_globals)
File "D:pythonScriptspipreqs.exe_main.py", line 9, in
File “d:pythonlibsite-packagespipreqspipreqs.py”, line 470, in main
init(args)
File “d:pythonlibsite-packagespipreqspipreqs.py”, line 409, in init
follow_links=follow_links)
File “d:pythonlibsite-packagespipreqspipreqs.py”, line 122, in get_all_imports
contents = f.read()
UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xad in position 368: illegal multibyte sequence
解决:
pipreqs ./ --encoding utf-8
之后会在项目文件夹下生成一个requirements.txt
安装依赖:
pip install -r requirements.txt
Tip:
自动生成的依赖清单,并不能保证所有依赖包含到,
可能有部分依赖文件需要自己手动pip。