requirements.txt文件格式:
requests==1.2.0
Flask==0.10.1
方法一:
在终端进入需要导出requirements.txt的虚拟环境
pip freeze > requirements.txt
pip的freeze命令用于生成将当前项目的pip类库列表生成 requirements.txt 文件(文件保存在home根目录中)
操作如下:
注:当需要利用 requirements.txt 文件安装python包,则将 requirements.txt 文件放在home根目录上。
方法二:
使用 pipreqs 用于生成 requirements.txt 文件
先安装pipreqs
pip install pipreqs
然后,找到需要导出requirements.txt的项目文件根目录,并在该目录打开终端,输入 pipreqs ./ --encoding=utf8 。
如下:
参考链接
1.https://blog.csdn.net/Irving_zhang/article/details/79087569
2.https://blog.csdn.net/orangleliu/article/details/60958525