I find that Mike Orr's answer from the virtual-env mailing list seems to be the best. Please note that the OP posted this question in both places.
Original mail content:
A few years ago, Debian created / usr / local / lib / pythonVERSION / site -packages, and compiled the Python binary to include it in the default search path. Ubuntu followed the Debian leader as usual. The Python developers did not like this because you came across a locally installed / usr / local / bin / python using the same directory site packages. Ubuntu finally decided to abandon the site packages and use dist-packages instead, the name they invented so that it would not interfere with anything. The history of the fault is somewhere there, if you google it, somewhere in Python an error tracker or SIG distutils or for example.
The system works, at least if you are using the Ubuntu virtual package. Some people have had problems using locally installed virtual Ubuntu because sys.path magic entries were not added or anything. I am not sure about the -no-site-packages because I never use this option: I run PIL and mysqldb from Ubuntu packages because it is sometimes difficult to compile their C dependencies. (Need right header files, Python ignores files headers, etc.)
So, Ubuntu Python packages are in / USR / Lib / pythonVERSION / distance-packages. Or that python support is for some reason. Locally installed Python packages are included in / usr / local / lib / pythonVERSION / dist -packages by default. Whenever I install the Ubuntu 9.04 system that I run:
$ sudo apt-get install python-setuptools (6.0c9) $ sudo apt-get install python-virtualenv (1.3.3) $ sudo easy_install pip $ sudo pip install virtualenvwrapper
Virtualenvs work fine, although I have not tried --no-site-packages.
I'm trying to deploy virtualenv, and the -no-site-packages flag doesn't seem to do anything with ubuntu. I installed virtualenv 1.3.3 with easy_install (which I updated to setuptools 0.6c9)
These versions are like in Ubuntu 9.04, so you make it more difficult on your own by installing them locally.
and everything seems to be installed in / usr / local / lib / python 2.6 / dist-packages
Yes
I assume that when installing a package using apt-get it is placed in / usr / lib / python2.6 / dist-packages /?
Yes
- Does it first have to go first? If I have a new version of the XYZ package installed in / usr / local / lib / python 2.6 / dist-packages / and older (from ubuntu repos / apt-get) in / usr / lib / python2.6 / dist-packages which is imported when i import xyz? I guess this is based on a list of paths, yes?
sys.path is scanned in order. The funny thing is that .pth eggs get sooner or later on the way than some people expect. But if you use pip for everything that it can do (for example, with the exception of installing pip itself, pre-compiled eggs and a snapshot of the local directory, which is a copy, not a link to an egg), you will not have many .pth eggs in any case.
- Why the hell is this so confusing? Is there something I'm missing here?
This is poorly documented. I figured this out by browsing the web.
- Will this affect the pip?
Yes, pip will automatically install / usr / local / library / pythonVERSION / site packages. Use "pip install -E $ VIRTUAL_ENV packagename" to install in virtualenv.