python 项目导出依赖库方法


python 项目导出依赖库方法

导出所有依赖库

此命令将会列出当前开发环境所有依赖库到requirements.txt文件中,相对较为冗杂。在项目根目录位置,执行:

pip freeze > requirements.txt

导出核心依赖库

此方法需要使用使用工具库 pipreqs。
首先安装:

pip install pipreqs

或者使用清华源安装
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pipreqs

之后进入项目根目录位置,执行:

pipreqs ./ --encoding utf-8