简体   繁体   English

通过bash脚本和pip在虚拟环境中安装python包

[英]Installing python packages in a virtual environment via bash script and pip

To clarify I have read these questions already: 为了澄清我已经阅读了这些问题:

How to source virtualenv activate in a Bash script 如何在Bash脚本中激活virtualenv激活

How to activate python virtual environment by shell script 如何通过shell脚本激活python虚拟环境

Activating virtualenv in Bash script not working 在Bash脚本中激活virtualenv不起作用

Bash: How _best_ to include other scripts? Bash:如何_best_包含其他脚本?

My goal is to create a script that will automate the process of installing several (roughly 27) python packages via pip in a virtual environment using (preferably) a bash script. 我的目标是创建一个脚本,该脚本将使用(最好)bash脚本在虚拟环境中通过pip自动安装几个(大约27个)python包的过程。

So far in bash scripts I have tried: 到目前为止,我尝试过bash脚本:

source env/bin/activate
pip install numpy Scipy ez_setup 

As well as 以及

activate() {
. ../.env/bin/activate
}

activate
pip install numpy Scipy ez_setup 

Neither of which works. 两者都不奏效。 What is the best way to approach this problem given it must be executable as part of a larger bash (or python) script? 解决此问题的最佳方法是什么,因为它必须可以作为更大的bash(或python)脚本的一部分执行?

Update: So I figured out my problem. 更新:所以我发现了我的问题。 The solution for me is to force the script to pull from the correct pip directory with 我的解决方案是强制脚本从正确的pip目录中拉出来

/env/bin/pip install numpy Scipy ez_setup

The second part is to break down the install instructions into each line because the registries were not being updated properly. 第二部分是将安装指令分解为每行,因为注册表未正确更新。

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

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