python项目导出依赖包requirements.txt文件

只导出当前项目依赖包

注意:使用 pip freeze > requirements.txt 会导出大量无用的文件,包括很多个包信息,其实这里是把你当前 python 环境的所有包的相关信息导出来了。如果我们只需导出当前项目所需的依赖包,我可以采用另外一种方式:pipreqs.

1、安装pipreqs:

pip install pipreqs

2、进入当前项目目录下,导包:

pipreqs ./

(导包完成会生成一个requirements.txt文件)

3、安装依赖的时候使用:

pip install -r requirements.txt

如果遇到编码错误UnicodeDecodeError,则将指定编码为utf8:

pipreqs ./ --encoding=utf8

你可能感兴趣的:(Python,python)