I am familiar with how a python virtualenv works and when we activate, it mainly modifies VIRTUAL_ENV
and PATH
variable. Primarily it adds the bin
directory of virtualenv to system PATH
and sets VIRTUAL_ENV
to point to the virtual env root directory.
As an experiment I did this using virtualenv (version 1.11.6):
# Created two fresh virtual environments
virtualenv /tmp/env1
virtualenv /tmp/env2
echo $PATH
> SOME_PATH_VALUE
# Play with env1
source /tmp/env1/bin/activate
echo $PATH
> /tmp/env1/bin:SOME_PATH_VALUE
pip list
> pip, setuptools, wsgiref
pip install wget
> pip, setuptools, `wget`, wsgiref
# Obviously env2 has pip, setuptools and wsgiref only as of now
export PATH=/tmp/env2/bin:$PATH
pip list
> pip, setuptools, wsgiref
With my experiments it was solely depending on PATH
variable for determining the installation path, but I am not sure if thats the whole picture. So the key questions are:
- How does pip know where to install the requested package?
- If my virtualenv is configured not to look for site-packages (ensured that the
no-global-site-packages.txt
file exists in correct location) andPATH
variable is correctly set, but pip install still looks into system site-packages, then how to debug this?