python项目生成requirements.txt
生成虚拟环境下所有的依赖包
pip freeze > requirements.txt
这种方式会将环境中的依赖包全都加入,如果使用的全局环境,则下载的所有包都会在里面,不管是不时当前项目依赖的。
只生成本项目所依赖包
使用 pipreqs ,github地址为: https://github.com/bndr/pipreqs
# 安装
pip install pipreqs
# 在当前目录生成
pipreqs . --encoding=utf8 --force
安装虚拟环境
使用requirements.txt安装依赖的方式:
pip install -r requirements.txt