Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

How do I reconfigure an installation of Python 2.7, on Snow Leopard, so that the OS uses the default 2.6 but leaves my 2.7 installation, and its installed modules, for use under virtualenv? Basically trying to fix the mistake of getting at 2.7 directly rather than through virtualenv.

Technicalia:

  • OSX 10.6.8
  • 2.7 installation was probably from source
  • 2.7 residing in /Library/Frameworks/Python.framework/Versions/2.7/bin/python
  • python2.6 at /usr/bin/python2.6, a symlink to /System/Library/Versions...
  • there exists a file /usr/bin/python; << /usr/bin/python -V >> returns Python 2.6.1
share|improve this question
    
what is your path? –  Mark Oct 31 '11 at 18:49
    
<< echo $PATH >>: /Library/Frameworks/Python.framework/Versions/2.7/bin, /Library/Frameworks/Python.framework/Versions/2.7/bin, /opt/local/bin, /opt/local/sbin, /Users/gimli/.rvm/bin, /Users/gimli/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/bin, [similar ruby-related items], /usr/local/bin, /usr/bin, /bin, /usr/sbin, /sbin, /usr/local/bin, /usr/X11/bin, /usr/local/mysql/bin –  chernevik Oct 31 '11 at 20:56
    
Just noticed the duplication of .../2.7/bin, I'll have to clean up .profile. –  chernevik Oct 31 '11 at 21:00

1 Answer 1

OS python scripts will use the default as the scripts look for /usr/bin/python not the one on the path.

If you want python at the command prompt to use 2.6 I would remove /Library/Frameworks/Python.framework/Versions/2.7/bin/ from the path.

To get the bare 2.7 python you will need to use the full path.

If virtualenv is not installed for 2.7 you need easy_install - which should be in /Library/Frameworks/Python.framework/Versions/2.7/bin /Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install virtualenv(if that is not there you should add distribute or setuptools.)

To create a 2/7 vitualenv run /Library/Frameworks/Python.framework/Versions/2.7/bin/python virtualenv.py ENV then running ENV/bin/python gives you the 2.7 version - as would running the activate script to add the virtualenv python to the from of your path for the rest of the Terminal session.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.