python VENV 环境 requirements.txt的生成、使用

 

python项目 requirements.txt 文件,记录所有依赖包及其精确的版本号。用于新环境部署。

在虚拟环境中pip生成命令(正常环境类似):

(venv) $ pip freeze >requirements.txt

安装或升级包后,最好更新这个文件。

requirements文件的内容示例如下:

amqp==1.4.9
anyjson==0.3.3
asn1crypto==0.24.0
Babel==2.6.0
bcrypt==3.1.4
billiard==3.3.0.23
celery==3.1.26.post2
certifi==2018.10.15
cffi==1.11.5
chardet==3.0.4
colorama==0.4.0
colorlog==3.1.4
cryptography==2.3.1

 

新环境部署,运行以下命令安装需要的包:

(venv) $ pip install -r requirements.txt


posted @ 2018-11-07 16:01  yoyo008  阅读(5196)  评论(0编辑  收藏  举报