使用pip freeze,如果是pip3则替换成pip3
pip3 freeze > requirements.txt
这种方式是把整个环境中的包都列出来了,如果是虚拟环境可以使用pipreqs
1.安装
pip3 install pipreqs
2.使用方法
先进入虚拟环境,cd到根目录下
然后输入命令:
pipreqs ./ --encoding=utf-8
结果为:
INFO: Successfully saved requirements file in ./requirements.txt