Note that there are some explanatory texts on larger screens.

plurals
  1. POVirtualenv using system packages when it should not
    primarykey
    data
    text
    <p>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. </p> <p>Why is this? How can I only work with the virtualenv packages when I have a virtualenv activated? </p> <p>I am on OS X, if it matters. </p> <p>Edit in response to Jeff's comments below:</p> <p>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.</p> <pre><code>(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 -&gt; python </code></pre> <p>With the ENV activated, "which python" and "which python2.6" both point to the ENV directory.</p> <pre><code>(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:~] $ </code></pre> <p>Moreover, the prompt is identical after using the executables at the command line. </p> <pre><code>(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. &gt;&gt;&gt; import psycopg2 &gt;&gt;&gt; psycopg2.__version__ '2.2.2 (dt dec ext pq3)' &gt;&gt;&gt; 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. &gt;&gt;&gt; import psycopg2 &gt;&gt;&gt; psycopg2.__version__ '2.0.13 (dt dec ext pq3)' &gt;&gt;&gt; quit() </code></pre> <p>The ~/ENV/lib/python2.6/site-packages directory contains the NEW version of psycopg2 (2.2.2):</p> <pre><code>(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 </code></pre> <p>However, importing psycopg2 at the different prompts imports two different versions. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload