2

from this question:

Manage python version in different virtualenv with pythonbrew

I followed the instructions of the answer and typed in:

pythonbrew venv create project1

After doing this, virtualenv was installed and this new venv was installed here:

user/.pythonbrew/venvs/Python-2.7.6/project1

What I would like to know is how I would be able to install dependencies within this virtualenv using pip?

Based on my current knowledge, I would assume that running the command to install dependencies from the generic terminal spot (user/) will make the dependencies get installed in the main pythonbrew install and not the virtual environment.

I am building multiple web projects using different python tools (but the same/latest python 2.7 version), so I would like to keep each project(and their different dependencies) separate.

2
  • Forget pythonbrew (even the author deems it "deprecated".) Just use plain virtualenv to create local (to current directory) virtual Python environments. And put your required modules in requirements.txt and run pip -r requirements.txt. Commented Jan 13, 2014 at 17:34
  • There are some major differences between pythonbrew and virtualenv which deem it necessary for me to use pythonbrew, otherwise I would use virtualenv exclusively. Commented Jan 13, 2014 at 17:37

3 Answers 3

1

Simply use that project's pip to install desired module.

In your case, for example:

user/.pythonbrew/venvs/Python-2.7.6/project1/bin/pip install mpipe

Dump the newly installed module's version:

user/.pythonbrew/venvs/Python-2.7.6/project1/bin/python -c 'import mpipe; print(mpipe.__version__)'

Output is:

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

1 Comment

Thanks for your answer. I believe pythonbrew has some baked in commands (as I discovered while trying to find the document in my own answer) for venv.
1

I think I have found the ideal solution here:

https://pypi.python.org/pypi/pythonbrew/

By running this:

pythonbrew venv use proj

And then running:

pip install -U django==x.x.x

It will install a dependency like django into the virtual environment, even if you have other versions of it.

Comments

0

You are correct in thinking that running pip in the terminal will update the entire system while running it in particular environment will only update that particular virtual environment.

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.