简体   繁体   English

通过脚本安装多个 python 模块

[英]install multiple python modules through a script

I have.tar files of multiple python modules and need to install these modules in a sequence.我有多个python模块的.tar文件,需要依次安装这些模块。 with the bash, I can simply iterate the directories one by one, and execute python setup.py install command.使用 bash,我可以简单地逐个迭代目录,然后执行 python setup.py install 命令。 but how to do the same with a python script.但是如何用 python 脚本做同样的事情。 I am not able to iterate directories in Python script.我无法在 Python 脚本中迭代目录。

the sample bash commands are like:-示例 bash 命令如下:-

sudo yum upgrade python-setuptools;
cd setuptools_scm-4.1.2;
/usr/bin/python setup.py install;
cd ../importlib_metadata-1.6.1;
/usr/bin/python setup.py install;
cd ../configparser-4.0.2;
/usr/bin/python setup.py install;

You can install packages listed in a text file called requirements file.您可以安装名为需求文件的文本文件中列出的软件包。 For example, if you have a file called requirements.txt containing the required modules that's needed to be installed.例如,如果您有一个名为 requirements.txt 的文件,其中包含需要安装的必需模块。 You can install them by using:您可以使用以下方法安装它们:

pip install -r requirements.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM