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

Closed
vbabiy opened this Issue Mar 14, 2011 · 16 comments

Projects

None yet

1 participant

@vbabiy

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 virtualenv.py 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

Notes:

  • 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 virtualenv.py 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 virtualenv.py
    --- a/virtualenv.py Wed Dec 16 23:46:38 2009 -0600
    +++ b/virtualenv.py Wed Dec 23 11:53:33 2009 -0500
    @@ -798,6 +798,7 @@
    virtual_lib)

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

@vbabiy

Bump!


Original Comment By: bobp
@vbabiy

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
@vbabiy

Bump!


Original Comment By: Ryan Wilcox
@vbabiy

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

$ /usr/bin/python -c "import sys;print sys.prefix"
/System/Library/Frameworks/Python.framework/Versions/2.6


Original Comment By: Philip Jenvey
@vbabiy

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
@vbabiy

Bump!


Original Comment By: Anonymous
@vbabiy

Bump!


Original Comment By: Whit Morriss
@vbabiy

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


Original Comment By: Anonymous
@vbabiy

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
@vbabiy

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

diff -r 8dd7663d9811 virtualenv.py

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

+++ b/virtualenv.py     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/Python.app/Contents/MacOS/%s' %

os.path.basename(sys.executable))

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

+            embedded_interpreter = os.path.join(

+                prefix,

+                'Resources/Python.app/Contents/MacOS/Python')

         # 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 http://groups.google.com/group/python-virtualenv/

         #

browse_thread/thread/17cab2f85da75951

         shutil.copy(

-                os.path.join(

-                    prefix, 'Resources/Python.app/Contents/MacOS/%s' %

os.path.basename(sys.executable)),

+                embedded_interpreter,

                 py_executable)


         # Copy the framework's dylib into the virtual

Original Comment By: Yusuke MURAOKA
@vbabiy

Bump!


Original Comment By: Anonymous
@vbabiy

Hi,

comment #10 patch isn't working.


Original Comment By: #10
@vbabiy

Patch by jbking in comment no. 10 works for me


Original Comment By: Daniel Hepper
@vbabiy

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
@vbabiy

[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
@vbabiy

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