Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1056365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:42:19+00:00 2026-05-16T17:42:19+00:00

I created a virtualenv environment with the –no-site-packages option. After activating the virtualenv, I

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:42:20+00:00Added an answer on May 16, 2026 at 5:42 pm

    I’ve been trying to replicate your problem but with no luck.

    Activating virtualenv leaves me with a prompt like this:

    jeff@DeepThought:~$ source ~/ENV/bin/activate
    (ENV)jeff@DeepThought:~$ 
    

    Mostly what this is doing is adding the ~/ENV/bin to the front of the search path so when I type “python” the version I have installed in that bin comes up first. In my case, I have 2.6 installed globally and 2.7 installed virtually.

    (ENV)jeff@DeepThought:~$ python
    Python 2.7 (r27:82500, Sep  8 2010, 20:09:26) 
    [GCC 4.4.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    

    What I find strange about your case is that you say you have your updated libraries in the virtual environment, but you are only able to access them with python2.6. Unless you have created it on your own, ~/ENV/bin should not even have a python2.6 executable. If you have activated virtualenv, typing python should bring you to the virtualenv python shell and typing python2.6 would bring you to the global python shell. If that were the case, you should be seeing the opposite of what you say is happening.

    The first thing I would do is check out what is being executed when you run python and python2.6:

    (ENV)jeff@DeepThought:~$ which python
    /home/jeff/ENV/bin/python
    (ENV)jeff@DeepThought:~$ which python2.6
    /usr/bin/python2.6
    

    This looks how I would expect it to. What does yours look like? If yours also looks like that, maybe you need to just go into ~/ENV/lib/python2.6/site-packages/ and remove the files that are giving you trouble, replacing them with the updated files.

    EDIT: alias takes priority over search path:

    jeff@DeepThought:~$ echo $PATH
    /home/jeff/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    jeff@DeepThought:~$ cat > /home/jeff/bin/hello.sh
    #!/bin/bash
    echo "hello world"
    jeff@DeepThought:~$ chmod +x ~/bin/hello.sh 
    jeff@DeepThought:~$ hello.sh
    hello world
    jeff@DeepThought:~$ which hello.sh
    /home/jeff/bin/hello.sh
    jeff@DeepThought:~$ alias hello.sh=/usr/bin/python
    jeff@DeepThought:~$ which hello.sh
    /home/jeff/bin/hello.sh
    jeff@DeepThought:~$ hello.sh
    Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
    [GCC 4.4.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like the change my zsh prompt style for every virtualenv instances that
I created the setup project for the application and I can see that the
I want to write some python package installing script in Python into virtualenv. I
Is there something similar to the Python utility virtualenv ? Basically it allows you
when I try to create a virtualenv that uses python2.5 I get the following
created an Eclipse plugin that contributes to the UI by a new project wizard
I created a program using dev-cpp and wxwidgets which solves a puzzle. The user
I created a few mediawiki custom tags, using the guide found here http://www.mediawiki.org/wiki/Manual:Tag_extensions I
I created a single page (with code behind .vb) and created Public intFileID As
I created an Interop user control in VS2005. When the user control is shown

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.