只导出当前项目依赖包
1、安装pipreqs:
pip install pipreqs
2、进入当前项目目录下,导包:
pipreqs ./
(导包完成会生成一个requirements.txt文件)
3、安装依赖的时候使用:
pip install -r requirements.txt
如果遇到编码错误UnicodeDecodeError,则将指定编码为utf8:
pipreqs ./ --encoding=utf8
Windows PowerShell 版权所有 (C) Microsoft Corporation。保留所有权利。 尝试新的跨平台 PowerShell https://aka.ms/pscore6 PS E:\bbrlargescreen> pipreqs ./ Traceback (most recent call last): File "D:\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, exec(code, run_globals) File "D:\Python310\Scripts\pipreqs.exe\__main__.py", line 7, in <module> File "D:\Python310\lib\site-packages\pipreqs\pipreqs.py", line 488, in main init(args) File "D:\Python310\lib\site-packages\pipreqs\pipreqs.py", line 415, in init candidates = get_all_imports(input_path, File "D:\Python310\lib\site-packages\pipreqs\pipreqs.py", line 115, in get_all_imports contents = f.read() UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 563: illegal multibyte sequence PS E:\bbrlargescreen> pipreqs ./ --encoding=utf8 INFO: Successfully saved requirements file in ./requirements.txt PS E:\bbrlargescreen>
标签:pipreqs,Python,py,导出,依赖,File,Python310,line,main From: https://www.cnblogs.com/ailuo9494/p/17126405.html