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?

2
  • 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. Commented Jun 23, 2015 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. Commented Jun 29, 2015 at 13:39

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.