交个朋友吧

python项目生成requirements.txt

很实用,转载自:https://www.cnblogs.com/shun7man/p/14080921.html

生成虚拟环境下所有的依赖包

pip freeze > requirements.txt

这种方式会将环境中的依赖包全都加入,如果使用的全局环境,则下载的所有包都会在里面,不管是不时当前项目依赖的。

只生成本项目所依赖包

使用 pipreqs ,github地址为: https://github.com/bndr/pipreqs

# 安装
pip install pipreqs
# 在当前目录生成
pipreqs . --encoding=utf8 --force

image

安装虚拟环境

使用requirements.txt安装依赖的方式:

pip install -r requirements.txt
posted @ 2025-04-08 09:46  PamShao  阅读(114)  评论(0)    收藏  举报