python on Mac

T

Thomas Nelson

I just purchased a new macbook (os 10.4.6), and I'm trying to install
python 2.4 on it. I downloaded and ran the two installers recommended
at http://www.python.org/download/mac/. Now I have IDLE, which runs
2.4.1, but typing "python" at a terminal still opens 2.3.5, because it
points to /usr/bin/python. Is there a way to run python 2.4 without
idle? If I want to do a unix style script, something like
#!/usr/bin/python
print "hello world"
what can I put on the first line that will cause python 2.4 to
interpret my code?

Thanks a lot.
THN
 
J

James Stroud

Thomas said:
I just purchased a new macbook (os 10.4.6), and I'm trying to install
python 2.4 on it. I downloaded and ran the two installers recommended
at http://www.python.org/download/mac/. Now I have IDLE, which runs
2.4.1, but typing "python" at a terminal still opens 2.3.5, because it
points to /usr/bin/python. Is there a way to run python 2.4 without
idle? If I want to do a unix style script, something like
#!/usr/bin/python
print "hello world"
what can I put on the first line that will cause python 2.4 to
interpret my code?

Thanks a lot.
THN

The python in /usr/bin is a link (to a link). You can do this:

sudo rm /usr/bin/python
sudo ln -s \
/System/Library/Frameworks/Python.framework/Versions/2.4/bin/python \
/usr/bin/python


This stupid firebird editor word-wraps (and I don't know how to turn
this completely annoying behavior off. Appearantly this is because it is
impossible to soft wrap text on the reader side, annoying NNTP veterans
everywhere--we just can't count on this hard to program behavior in most
mail readers because its so impossible to program for. Its been this way
since reader-client word wrapping was predicted to exist at MIT in the
1970's.) so get a unix guru to help you with that last command if you
really don't know what's going on.

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
 
T

Thomas Nelson

There is no 2.4 in my Versions folder, only 2.3 and current. Should
one of the installers have created this directory? Which one?

THN
 
T

Thomas Nelson

Thanks to you both. I downloaded the dmg suggested, and trustingly
typed:
sudo rm /usr/bin/python
sudo ln -s /usr/local/bin/python2.4 /usr/bin/python
And now my command line and scripts behave the way I expect. Thanks
again.

THN
 
P

pierreth

You removed /usr/bin/python! This is a really bad idea. You should
never modify /usr/bin because the system is expecting it. This is why
the new installation is in /usr/local/bin.

Modify your /usr/local instead are change your .login file instead. It
is much safer.
 
R

Robert Kern

James said:
The python in /usr/bin is a link (to a link). You can do this:

sudo rm /usr/bin/python
sudo ln -s \
/System/Library/Frameworks/Python.framework/Versions/2.4/bin/python \
/usr/bin/python

No, for the love of all that is holy, don't do that! OS X depends on stuff in
/usr/bin/. Don't pull the carpet out from under your OS!

The python executables from the Python 2.4 installer are installed to
/usr/local/bin/. I believe that the Universal binary that Alex linked to takes
care of adjusting the PATH environment variable such that this is exposed.

--
Robert Kern
(e-mail address removed)

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
R

Robert Kern

Robert said:
James Stroud wrote:

No, for the love of all that is holy, don't do that! OS X depends on stuff in
/usr/bin/. Don't pull the carpet out from under your OS!

C.f.:

"FAQ 5.7 Describe Apple's Framework implementation of Python and how that
affects me adding new Python implementations"

http://pythonmac.org/wiki/FAQ#head-392d16c2e6e49d6de6555634fc94759989464b5a


--
Robert Kern
(e-mail address removed)

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
L

Lou Pecora

James Stroud said:
The python in /usr/bin is a link (to a link). You can do this:

sudo rm /usr/bin/python
sudo ln -s \
/System/Library/Frameworks/Python.framework/Versions/2.4/bin/python \
/usr/bin/python

YIKES! Don't do that. Don't mess with Apple's python. Not
recommended. Check the MacPython FAQ and Wiki pages. Python 2.4 was
installed in /usr/local/bin. You should put that in your $PATH variable
Before /usr/bin. That will cause the new Python to be launched.

-- Lou Pecora (my views are my own) REMOVE THIS to email me.
 
G

gene tani

Lou said:
YIKES! Don't do that. Don't mess with Apple's python. Not
recommended. Check the MacPython FAQ and Wiki pages. Python 2.4 was
installed in /usr/local/bin. You should put that in your $PATH variable
Before /usr/bin. That will cause the new Python to be launched.

some afterthoughts:

- look at Oreilly's "OS X Tiger for Unix Geeks" before you do anything
that'll break OS X. Just in case you get the idea to upgrade the perl
that OS X installed, don't remove the one in /usr/bin either.

- investigate the Activestate disk image for OS X/Intel. I say
"investigate" cause i don't have any experience with OS X/Intel, but
the Activestate releases i've used for Windows and OS X in the past
have all been very high quality.
 
T

Thomas Nelson

Well, as I stated in post, I've already replaced the link at
/usr/bin/python. I'm not clear why that's unhealthy. Should I change
it back to whatever it was before? I guess maybe it was
/System/Library/Frameworks/Python.framework/Versions/Current/bin/python
?
Thanks,
THN
 
R

Robert Kern

Thomas said:
Well, as I stated in post, I've already replaced the link at
/usr/bin/python. I'm not clear why that's unhealthy.

The FAQ describes why it's unhealthy in detail.

"FAQ 5.7 Describe Apple's Framework implementation of Python and how that
affects me adding new Python implementations"

http://pythonmac.org/wiki/FAQ#head-392d16c2e6e49d6de6555634fc94759989464b5a
Should I change
it back to whatever it was before? I guess maybe it was
/System/Library/Frameworks/Python.framework/Versions/Current/bin/python
?

[src]$ ls -l /usr/bin/python
lrwxr-xr-x 1 root wheel 9 May 1 2005 /usr/bin/python -> python2.3
[src]$ ls -l /usr/bin/python2.3
lrwxr-xr-x 1 root wheel 72 May 1 2005 /usr/bin/python2.3 ->
.../../System/Library/Frameworks/Python.framework/Versions/2.3/bin/python

--
Robert Kern
(e-mail address removed)

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
T

Thomas Nelson

Ok, I fixed my /usr/bin/python and added /usr/public/bin/ to my PATH in
..profile. Everything seems ok now.
Thanks again to everyone for their help.

THN
 
A

Alex Martelli

Lawrence D'Oliveiro said:
Is there any way to put it back, short of a full system reinstall?

There's a free 3rd party tool known as Pacifist to extract part-installs
from Apple's system DVDs, but I'm not sure how you'd apply it to Apple's
Python -- try asking around on the Pacifist mailing list or site...


Alex
 
L

Lawrence D'Oliveiro

There's a free 3rd party tool known as Pacifist to extract part-installs
from Apple's system DVDs...

So there's no simple equivalent of "rpm --replace-pkgs"?
 
A

Alex Martelli

Lawrence D'Oliveiro said:
So there's no simple equivalent of "rpm --replace-pkgs"?

Never heard of one, but you should double-check on Macintosh-related
groups, where you're more likely to find relevant expertise.


Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,292
Messages
2,571,494
Members
48,184
Latest member
XRUBennie9

Latest Threads

Top