0

I have two python 2.5.4 installations on my Snow Leopard, don't ask why.

When I run just "python" from the cmdline, build 5363 is started. When I run /usr/bin/python2.5 then build 5646 (the one I need) is started. Before you ask, build number is not the only difference between those but also the "type" of the build, so I really can't even start getting somewhere with this 5363.

Problem is, the app I need crashes (exception in wxPython, couldn't google that one), and I'm suspicious that when I start main app with correct python build, threads are started with the wrong one (it happened before with the same app, on another system).

How do I go about changing "default" python 2.5 to start the right build?

my PATH is:

/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

which python returns only:

/Library/Frameworks/Python.framework/Versions/Current/bin/python

ls -la /usr/bin/python* returns:

-rwxr-xr-x  2 root  wheel  86000 Sep 25  2010 /usr/bin/python
-rwxr-xr-x  5 root  wheel    925 Sep 25  2010 /usr/bin/python-config
lrwxr-xr-x  1 root  wheel     75 Sep 25  2010 /usr/bin/python2.5 -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
lrwxr-xr-x  1 root  wheel     82 Sep 25  2010 /usr/bin/python2.5-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5-config
lrwxr-xr-x  1 root  wheel     75 Sep 25  2010 /usr/bin/python2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
lrwxr-xr-x  1 root  wheel     82 Sep 25  2010 /usr/bin/python2.6-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config
-rwxr-xr-x  2 root  wheel  86000 Sep 25  2010 /usr/bin/pythonw
lrwxr-xr-x  1 root  wheel     76 Sep 25  2010 /usr/bin/pythonw2.5 -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw2.5
lrwxr-xr-x  1 root  wheel     76 Sep 25  2010 /usr/bin/pythonw2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6

ls -la /usr/local/bin/python* returns:

lrwxr-xr-x  1 root  wheel  68 Apr 22  2010 /usr/local/bin/python -> ../../../Library/Frameworks/Python.framework/Versions/2.5/bin/python
lrwxr-xr-x  1 root  wheel  75 Apr 22  2010 /usr/local/bin/python-config -> ../../../Library/Frameworks/Python.framework/Versions/2.5/bin/python-config
lrwxr-xr-x  1 root  wheel  71 Apr 22  2010 /usr/local/bin/python2.5 -> ../../../Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
lrwxr-xr-x  1 root  wheel  78 Apr 22  2010 /usr/local/bin/python2.5-config -> ../../../Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5-config
lrwxr-xr-x  1 root  wheel  69 Apr 22  2010 /usr/local/bin/pythonw -> ../../../Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw
lrwxr-xr-x  1 root  wheel  72 Apr 22  2010 /usr/local/bin/pythonw2.5 -> ../../../Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw2.5

I'm neither python nor *nix guru, add Mac to the mix and I feel pretty helpless...

Please help!

  • By the way, `build 5363` is the version of the gcc compiler that Python was built with; it has nothing to do with the version of Python itself. That information is in the previous line. –  Jul 30 '11 at 06:13

2 Answers2

2

It's not unusual to have more than one Python instance of the same version installed on Mac OS X.

It looks like you probably installed a python2.5 from python.org (that's the one symlinked in /usr/local/bin) but now you just want to use the Apple-supplied system Python 2.5 (in /usr/bin). What's causing the former to be found first is your shell execution path. The /usr/local/bin/python actually points to a file within

/Library/Frameworks/Python.framework/Versions/Current/bin/

which is part of the python.org installation. By default, the python.org installers modify your shell startup files to insert this directory at the start of your path. To undo that, you can restore your old startup file. If you are using the default bash shell, the startup file is named .bash_profile and the Python installer probably saved a copy of your original startup file as .bash_profile.pysave. From a Terminal session, you can inspect and restore the original file doing something like this:

$ cd $HOME
$ ls .*.pysave
.bash_profile.pysave  .profile.pysave
#
# compare the current file to the original saved file
#
# You'll probably see something like the following:
#
$ diff .bash_profile .bash_profile.pysave
4c4
---> # Setting PATH for MacPython 2.5
13c13
< PATH="/Library/Frameworks/Python.framework/Versions/2.5/bin:${PATH}"
---
#
# If so, it is safe to copy the saved file back and not lose
# any other changes you might have made
#
$ cp -p .bash_profile.pysave .bash_profile
#
# Then you will need to start a new Terminal session to see the changed PATH

If you prefer or if the .pysave file isn't found, you can manually edit the file to remove the extra directory.

  • Thanks man! I have changed this manually, so just "python" in terminal now starts the right version of 2.5.4 python. It turns out that app still crashes with same exception, but one nightmare less to debug... –  Jul 31 '11 at 05:48
0

Save yourself the headache and use Pythonbrew to manage your different python versions. No need to mess with symlinks and such. Very easy to install and use.

Chris Ledet
  • 101
  • 2
  • 1
    Interesting but that doesn't really help the OP solve the immediate problem. He has working Pythons and doesn't need to build new ones. The issue is his shell profile. –  Jul 30 '11 at 07:17