简体   繁体   English

使用脚本安装python软件包

[英]Installing python packages with script

I have a python script that use additional libraries. 我有一个使用其他库的python脚本。 I want to write a additional script for downloading these needed packages. 我想编写一个额外的脚本来下载这些所需的软件包。 That script will run by the user before run the actual script. 该脚本将由用户在运行实际脚本之前运行。 I am using Linux environment and all packages downloaded with pip or sudo from command line. 我正在使用Linux环境,并且从命令行使用pip或sudo下载了所有软件包。 What is the proper way to do serve that kind of script? 做这种脚本的正确方法是什么? Is setup.py created for that purpose? 是否为此创建了setup.py?

There is a Pypi way to do that, use requirements.txt file. 有一种Pypi方式可以做到这一点,请使用requirements.txt文件。

# requirements.txt
numpy==1.5.1
scipy==0.9.0

Then run: 然后运行:

pip install -r requirements.txt

You can use pip freeze to get the currently installed packages. 您可以使用pip freeze获取当前安装的软件包。

pip freeze | grep numpy
# numpy==1.5.1

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

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