I created a virtualenv environment with the --no-site-packages option. After activating the virtualenv, I noticed that importing psycopg2 at the "python" prompt would import the out of date system library I have but importing it at the "python2.6" prompt would import the newer version of the library I installed into the virtualenv.
Why is this? How can I only work with the virtualenv packages when I have a virtualenv activated?
I am on OS X, if it matters.
Edit in response to Jeff's comments below:
There are both "python" and "python2.6" executables in my virtualenv /bin directory. "python2.6" is a symbolic link to "python" and "python" is a binary.
(ice_development)[jacob@Beagle:~] $ ls -l Virtualenv/ice_development/bin/
total 264
-rw-r--r-- 1 jacob staff 2086 Sep 8 18:13 activate
.....
-rwxr-xr-x 1 jacob staff 50720 Sep 8 18:13 python
lrwxr-xr-x 1 jacob staff 6 Sep 8 18:13 python2.6 -> python
With the ENV activated, "which python" and "which python2.6" both point to the ENV directory.
(ice_development)[jacob@Beagle:~] $ which python
/Users/jacob/Virtualenv/ice_development/bin/python
(ice_development)[jacob@Beagle:~] $ which python2.6
/Users/jacob/Virtualenv/ice_development/bin/python2.6
(ice_development)[jacob@Beagle:~] $
Moreover, the prompt is identical after using the executables at the command line.
(ice_development)[jacob@Beagle:~] $ python2.6
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> psycopg2.__version__
'2.2.2 (dt dec ext pq3)'
>>> quit()
(ice_development)[jacob@Beagle:~] $ python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> psycopg2.__version__
'2.0.13 (dt dec ext pq3)'
>>> quit()
The ~/ENV/lib/python2.6/site-packages directory contains the NEW version of psycopg2 (2.2.2):
(ice_development)[jacob@Beagle:~] $ ls Virtualenv/ice_development/lib/python2.6/site- packages/
Twisted-10.1.0-py2.6-macosx-10.6-universal.egg setuptools-0.6c11-py2.6.egg
easy-install.pth setuptools.pth
pip-0.7.2-py2.6.egg txpostgres-0.3.0-py2.6.egg
psycopg2 zope.interface-3.6.1-py2.6-macosx- 10.6-universal.egg
psycopg2-2.2.2-py2.6.egg-info
However, importing psycopg2 at the different prompts imports two different versions.