virtualenv not working with default Python on Mac OS 10.6 #50

vbabiy opened this Issue Mar 14, 2011 · 16 comments


None yet

1 participant


Virtualenv doesn't work correctly with the default system python (2.6) on Mac OS 10.6 (Snow Leopard).

To reproduce:

unpack the 1.4.3 package

cd virtualenv-1.4.3

python foo

This yields:

New python executable in foo/bin/python
ERROR: The executable foo/bin/python is not functioning
ERROR: It thinks sys.prefix is '/System/Library/Frameworks/Python.framework/Versions/2.6' (should be '/private/tmp/virtualenv-1.4.3/foo')
ERROR: virtualenv is not compatible with this system or executable


  • This only happens with python2.6 (the system default). It works fine if you specify python2.5.
  • sys.prefix seems different between python2.5 and python2.6 on SL ** 2.5 *** /System/Library/Frameworks/Python.framework/Versions/2.5 ** 2.6 *** /usr/bin/../../System/Library/Frameworks/Python.framework/Versions/2.6
  • I 'fixed' the problem for me by modifying and adding a call to os.path.abspath on the prefix variable before the call to install_name_tool. Below is the diff of my change against the hg trunk:

    diff -r 67b57115a9ef
    --- a/ Wed Dec 16 23:46:38 2009 -0600
    +++ b/ Wed Dec 23 11:53:33 2009 -0500
    @@ -798,6 +798,7 @@

         # And then change the install_name of the copied python executable
    • prefix = os.path.abspath(prefix) try: call_subprocess( ["install_name_tool", "-change",



Original Comment By: bobp

instead of abspath, i had to use os.path.realpath due to my slightly
eccentric setup having a symlink from the Frameworks dir to the actual install
location (using homebrew).

Original Comment By: Edward George


Original Comment By: Ryan Wilcox

I can't reproduce the problem on 10.6.2/virtualenv 1.4.5. My sys.prefix seems

$ /usr/bin/python -c "import sys;print sys.prefix"

Original Comment By: Philip Jenvey

I have some issues with python version (I've build Python from source and
replaced it with system's default) and virtualenv on OSX too and as workaround
I create virtual environments with option "-p which python" and it seems to
work fine.

Original Comment By: Lukasz Balcerzak


Original Comment By: Anonymous


Original Comment By: Whit Morriss

I get this issue with system's Python 2.5.4 on MacOSX 10.6.3 and virtualenv

Original Comment By: Anonymous

After some digging it looks like the problem is cause by the fact that all
Python 2.5 related scripts (easy_install, virtualenv, etc.) are using
#!/usr/bin/python2.5 which is a symlink to system Python

Original Comment By: Anonymous

In my case, the issue was that system python(2.6) on osx(10.6) is capitalized.

diff -r 8dd7663d9811

--- a/     Thu Apr 22 03:15:11 2010 -0500

+++ b/     Sat May 22 14:53:47 2010 +0900

@@ -774,14 +774,20 @@

     if 'Python.framework' in prefix:

         logger.debug('MacOSX Python framework detected')

+        embedded_interpreter = os.path.join(

+            prefix,

+            'Resources/' %


+        if not os.path.exists(embedded_interpreter):

+            embedded_interpreter = os.path.join(

+                prefix,

+                'Resources/')

         # Make sure we use the the embedded interpreter inside

         # the framework, even if sys.executable points to

         # the stub executable in ${sys.prefix}/bin

         # See




-                os.path.join(

-                    prefix, 'Resources/' %


+                embedded_interpreter,


         # Copy the framework's dylib into the virtual

Original Comment By: Yusuke MURAOKA


Original Comment By: Anonymous


comment #10 patch isn't working.

Original Comment By: #10

Patch by jbking in comment no. 10 works for me

Original Comment By: Daniel Hepper

Can someone confirm that [Author: jezdez

Age: 8 months ago

Fixed 32 - Partially reverted the changes made in r03bf4040094c to fix setting
up cross Python version virtualenv.">r312:4f8d56657fd3]1 fixes this?

Original Comment By: Jannis Leidel

[Author: jezdez

Age: 8 months ago

Fixed 32 - Partially reverted the changes made in r03bf4040094c to fix setting
up cross Python version virtualenv.">r312:4f8d56657fd3]1 resolves this issue
for me.

Original Comment By: Dan Callahan

Thanks, closing...

Original Comment By: Jannis Leidel
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment