Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make virtualenv inherit specific packages from your global site-packages

People also ask

How do I inherit global site packages?

The settings gives your virtual environment access to the global site-packages. Select the Inherit global site-packages checkbox if you want that all packages installed in the global Python on your machine to be added to the virtual environment you're going to create.

Can virtualenv access global packages?

If you build with virtualenv --system-site-packages ENV, your virtual environment will inherit packages from /usr/lib/python2. 7/site-packages (or wherever your global site-packages directory is). This can be used if you have control over the global site-packages directory, and you want to depend on the packages there.


Create the environment with virtualenv --system-site-packages . Then, activate the virtualenv and when you want things installed in the virtualenv rather than the system python, use pip install --ignore-installed or pip install -I . That way pip will install what you've requested locally even though a system-wide version exists. Your python interpreter will look first in the virtualenv's package directory, so those packages should shadow the global ones.


You can use the --system-site-packages and then "overinstall" the specific stuff for your virtualenv. That way, everything you install into your virtualenv will be taken from there, otherwise it will be taken from your system.