- If I have a certain package installed both in the global site-packages and in the local one, which package will get imported? Will that even work or will I get an error?
- Which packages should I put in the global site-packages and which in the local one?
views:
206answers:
2Newly created virtual environment by default have access to global site-packages directory, unless created with --no-site-packages. Calling easy_install (installing new packages) with certain environment activated will cause local overwrite of already existing ones in global site-packages (similar to inheritance). Environment will use its own local packages, when missing - global ones.
The previous answer wraps up question 1 but ignores question 2.
The general best practice I've seen for which packages to put globally:
First, the core Python packages, as these don't change with backwards-incompatible issues unless you're upgrading a major version, and you'll want whatever security fixes from a python upgrade to apply automatically to your virtualenvs.
Second, packages that are a pain to easy_install or pip install into each individual virtualenv but that don't change very often -- MySQLdb/psycopg and PIL, for example.
Pretty much everything else should go into your virtualenv's packages (I highly recommend using pip requirements files and virtualenvwrapper to make this minimally painful and easy to set up on other machines).