2

To clarify I have read these questions already:

How to source virtualenv activate in a Bash script

How to activate python virtual environment by shell script

Activating virtualenv in Bash script not working

Bash: How _best_ to include other scripts?

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.

So far in bash scripts I have tried:

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?

Community
  • 1
  • 1
Lexa Gaffer
  • 71
  • 1
  • 6
  • `source env/bin/activate` should work - is there any output? The name of the venv should appear in brackets prepended to your terminal prompt. It's possible you may have to execute `scl enable python27 bash` if you are in a remote environment. – russdot Jun 23 '15 at 21:23
  • In this case I'm actually not working in a remote environment, but yes this is what I had expected too, yet it doesn't appear to be the case. – Lexa Gaffer Jun 29 '15 at 13:39

1 Answers1

4

Update: So I figured out my problem. The solution for me is to force the script to pull from the correct pip directory with

/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.

Lexa Gaffer
  • 71
  • 1
  • 6