Search code examples
pythonmacossetuptoolsdistutils

setup.py install location?


I'm running Mac OS X Lion 10.7.1 that has both python 2.6 and 2.7 installed. I've made 2.6 my default version. I am trying to install a package and it installs to 2.7. My setup looks like this:

~:hi› which python
/usr/bin/python

~:hi› python -V
Python 2.6.6

~:hi› python
Python 2.6.6 (r266:84292, Jun 16 2011, 16:59:16) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.prefix
'/System/Library/Frameworks/Python.framework/Versions/2.6'
>>> sys.exec_prefix
'/System/Library/Frameworks/Python.framework/Versions/2.6'

Shouldn't it be installed in 2.6 site-packages? Am I misunderstanding how this ought to work?

Edit

  • The package in question is virtuanenvwrapper

  • I made 2.6 my default version like so:

    defaults write com.apple.versioner.python Version 2.6
    
  • I tried installing it like this:

    sudo python setup.py install
    sudo /usr/bin/python setup.py install
    

Solution

  • When setup.py installs a Python package, it pays no attention to the Apple system settings. The only thing it knows is what version of Python you use to invoke it. If you say:

    python2.6 setup.py …
    

    then that version gets used, and the same with

    python2.7 setup.py …
    

    If you use the first of these two commands, does the package get installed under 2.6 like you want? My guess is that the shell that sudo runs might have 2.7 as its default, regardless of which Python your normal shell wants to use. What happens if you say:

    sudo python -V