Dante
Dante

Reputation: 11274

How to get pip to install packages into the virtual environment?

On Windows 8, i have the following structure for a Python 3 project:

../Project/
../Project/app/app.py
../Project/app/setup.py

From the app folder, i invoke the following commands to create and enter into a virtual environment:

pyvenv.py venv
cd venv\Scripts
activate.bat
cd ../..

Now i would like to install the Nose unit testing framework into my virtual environment:

pip install nose

... and Nose gets installed into the global folder (In my case, C:\Python33).

When i invoke python setup.py install, my custom module gets installed to the virtual environment. Why doesn't PIP do the same?

Upvotes: 11

Views: 4807

Answers (1)

alko
alko

Reputation: 48357

It works well for me after following docs:

Common installation tools such as Distribute and pip work as expected with venvs - i.e. when a venv is active, they install Python packages into the venv without needing to be told to do so explicitly. Of course, you need to install them into the venv first: this could be done by running distribute_setup.py with the venv activated, followed by running easy_install pip. Alternatively, you could download the source tarballs and run python setup.py install after unpacking, with the venv activated.

Upvotes: 6

Related Questions