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.

Community
  • 1
  • 1
Joe
  • 3,120
  • 3
  • 25
  • 30
  • 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``. – Velimir Mlaker Jan 13 '14 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. – Joe Jan 13 '14 at 17:37

3 Answers3

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
Velimir Mlaker
  • 10,664
  • 4
  • 46
  • 58
  • 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. – Joe Jan 13 '14 at 19:05
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.

Joe
  • 3,120
  • 3
  • 25
  • 30
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.

matcheek
  • 4,887
  • 9
  • 42
  • 73