YPCrumble
YPCrumble

Reputation: 28682

In what directory does virtualenvwrapper store site packages by default?

Virtualenvwrapper provides several variables:

$VIRTUALENVWRAPPER_ENV_BIN_DIR       
$VIRTUALENVWRAPPER_PROJECT_FILENAME  
$VIRTUALENVWRAPPER_SCRIPT            
$VIRTUALENVWRAPPER_VIRTUALENV_CLONE
$VIRTUALENVWRAPPER_HOOK_DIR          
$VIRTUALENVWRAPPER_PYTHON            
$VIRTUALENVWRAPPER_VIRTUALENV        
$VIRTUAL_ENV

I believe I am finding my virtual environment by cd $VIRTUALENVWRAPPER_HOOK_DIR and going to the name of the environment I created (cd my_environment).

That has three directories: bin, include and lib. Unfortunately, none of these seems to contain the site-packages directory.

Where would I go to find these site-packages?

Upvotes: 2

Views: 316

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1121894

site-packages is located in the lib/python{major}.{minor}/ subdirectory of your virtualenv.

e.g. in a Python 2.7 virtualenv:

$ ls -d lib/python?.?/site-packages/
lib/python2.7/site-packages/

but in a Python 3.4 virtualenv the version number again matches:

$ ls -d lib/python?.?/site-packages/
lib/python3.4/site-packages/

You can use:

$VIRTUAL_ENV/lib/`$VIRTUAL_ENV/bin/python -c "import sys; print('python{0.major}.{0.minor}'.format(sys.version_info))"`/site-packages/

if you wanted an absolute path, using the currently active virtualenv Python binary to produce the version number.

Upvotes: 3

Related Questions