Fork me on GitHub

Python之项目依赖包管理

Python之项目依赖包管理

前言

Python项目会涉及到各种依赖包的安装问题,如果环境改变如何快速将所有依赖的包记录下来并快速的在新环境中安装好?以下我们来解决这个问题。

解决方案

生成现有环境依赖包列表

1
2
3
4
5
6
7
[root@linux-node8 ~]# pip freeze >requirements.txt
[root@linux-node8 ~]# cat requirements.txt
backports.ssl-match-hostname==3.4.0.2
chardet==2.2.1
configobj==4.7.2
decorator==3.4.0
iniparse==0.4

新环境快速安装项目依赖包

1
[root@linux-node8 ~]# pip install -r requirements.txt

相关参数说明

1
2
3
4
pip freeze
即:Output installed packages in requirements format.
pip install -r requirements.txt:
即:-r, --requirement <file> Install from the given requirements file. This option can be used multiple times.

参考资料

======================================================
希望各位朋友支持一下

本文作者:dongsheng
本文地址https://mds1455975151.github.io/archives/ba45f1d3.html
版权声明:转载请注明出处!

坚持技术分享,您的支持将鼓励我继续创作!