views:

248

answers:

3

After updateing to mac osx 10.6 I had to switch back to python 2.5 in order to make virtual env work. But still I can not start my turbogears project. Paster is giving this :

Traceback (most recent call last):
  File ".../tg2env/bin/paster", line 5, in <module>
    from pkg_resources import load_entry_point
  File ".../tg2env/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 657, in <module>
  File ".../tg2env/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 660, in Environment
  File ".../tg2env/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 55, in get_supported_platform
  File ".../tg2env/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 186, in get_build_platform
  File ".../tg2env/lib/python2.5/distutils/__init__.py", line 14, in <module>
    exec open(os.path.join(distutils_path, '__init__.py')).read()
IOError: [Errno 2] No such file or directory: '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/__init__.py'

Any ideas? Thanks.

A: 

Why did you need to switch back to 2.5 to make virtualenv work? I have upgraded to 10.6 and am happily using virtualenv in Python 2.6.

Daniel Roseman
I switched back because I thought this will solve the issue. Also I need to keep the TG Application 2.5 compatible.
Roland
A: 

Probably eggs are installed for 2.6 distro. Please run in your terminal:

defaults write com.apple.versioner.python Version 2.5
export VERSIONER_PYTHON_VERSION=2.5
sudo easy_install virtualenv

Check out the second line, it should change python version for current terminal session.

dgl@dgl:~/ > python
Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51) 
...
dgl@dgl:~/ > export VERSIONER_PYTHON_VERSION=2.5
dgl@dgl:~/ > python
Python 2.5.4 (r254:67916, Jul  7 2009, 23:51:24) 
...
Dmitry Gladkov
Seems to still use Python 2.6:Best match: virtualenv 1.3.4Processing virtualenv-1.3.4-py2.6.eggvirtualenv 1.3.4 is already the active version in easy-install.pthInstalling virtualenv script to /usr/local/binUsing /Library/Python/2.6/site-packages/virtualenv-1.3.4-py2.6.eggProcessing dependencies for virtualenvFinished processing dependencies for virtualenv
Roland
Sorry, I forgot the second line. Now everything should be fine.
Dmitry Gladkov
A: 

As you've seen, in Snow Leopard 10.6, Apple supplies both a Python 2.6.2 (the default for /usr/bin/python) and a legacy Python 2.5.4 (/usr/bin/python2.5). The heart of both live in the /System/Library/Frameworks/Python.framework. In general, everything under /System is supplied and managed by Apple; it should not be modified by anyone else.

If that message is to be believed, your 10.6 installation is faulty.

$ cd /System/Library/Frameworks/Python.framework/Versions
$ ls -l
total 8
drwxr-xr-x  5 root  wheel  272 Sep  5 10:18 2.3/
drwxr-xr-x  9 root  wheel  408 Sep  5 10:43 2.5/
drwxr-xr-x  9 root  wheel  408 Sep  5 10:43 2.6/
lrwxr-xr-x  1 root  wheel    3 Sep  5 10:18 Current@ -> 2.6
$ ls -l 2.5/lib/python2.5/distutils/__init__.py
-rw-r--r--  1 root  wheel  635 Jul  7 23:55 2.5/lib/python2.5/distutils/__init__.py

$ /usr/bin/python2.5
Python 2.5.4 (r254:67916, Jul  7 2009, 23:51:24) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils
>>>

Check to see that file exists and with the correct permissions. If not, you should figure out what else is wrong with your /System and consider restoring from a backup or just reinstalling Snow Leopard.

Ned Deily