By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,526 Members | 1,895 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,526 IT Pros & Developers. It's quick & easy.

python on Mac

P: n/a
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

Apr 6 '06 #1
Share this Question
Share on Google+
16 Replies


P: n/a
Thomas Nelson wrote:
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/
Apr 6 '06 #2

P: n/a
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

Apr 6 '06 #3

P: n/a
Thomas Nelson <th*@mail.utexas.edu> wrote:
...
at http://www.python.org/download/mac/. Now I have IDLE, which runs


Darn, that page needs to be fixed -- it's out of date!-( Sorry...

See instead <http://www.python.org/download/releases/2.4.3/> and
download
<http://www.python.org/ftp/python/2.4.3/Universal-MacPython-2.4.3.dmg>,
you should be much happier.
Alex
Apr 6 '06 #4

P: n/a
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

Apr 6 '06 #5

P: n/a
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.

Apr 6 '06 #6

P: n/a
James Stroud wrote:
Thomas Nelson wrote:
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


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
ro*********@gmail.com

"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

Apr 6 '06 #7

P: n/a
Robert Kern wrote:
James Stroud wrote:

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!


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-3...94759989464b5a
--
Robert Kern
ro*********@gmail.com

"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

Apr 6 '06 #8

P: n/a
In article <e1**********@daisy.noc.ucla.edu>,
James Stroud <js*****@ucla.edu> wrote:
Thomas Nelson wrote:
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


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.
Apr 6 '06 #9

P: n/a

Lou Pecora wrote:
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.

Apr 6 '06 #10

P: n/a
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

Apr 6 '06 #11

P: n/a
Thomas Nelson wrote:
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-3...94759989464b5a
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
ro*********@gmail.com

"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

Apr 6 '06 #12

P: n/a
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

Apr 6 '06 #13

P: n/a
In article <11**********************@i39g2000cwa.googlegroups .com>,
"pierreth" <pt*********@yahoo.ca> wrote:
You removed /usr/bin/python! This is a really bad idea


Is there any way to put it back, short of a full system reinstall?
Apr 7 '06 #14

P: n/a
Lawrence D'Oliveiro <ld*@geek-central.gen.new_zealand> wrote:
In article <11**********************@i39g2000cwa.googlegroups .com>,
"pierreth" <pt*********@yahoo.ca> wrote:
You removed /usr/bin/python! This is a really bad idea


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
Apr 10 '06 #15

P: n/a
In article <1h*****************************@yahoo.com>,
al*****@yahoo.com (Alex Martelli) wrote:
Lawrence D'Oliveiro <ld*@geek-central.gen.new_zealand> wrote:
In article <11**********************@i39g2000cwa.googlegroups .com>,
"pierreth" <pt*********@yahoo.ca> wrote:
>You removed /usr/bin/python! This is a really bad idea


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...


So there's no simple equivalent of "rpm --replace-pkgs"?
Apr 11 '06 #16

P: n/a
Lawrence D'Oliveiro <ld*@geek-central.gen.new_zealand> wrote:
In article <1h*****************************@yahoo.com>,
al*****@yahoo.com (Alex Martelli) wrote:
Lawrence D'Oliveiro <ld*@geek-central.gen.new_zealand> wrote:
In article <11**********************@i39g2000cwa.googlegroups .com>,
"pierreth" <pt*********@yahoo.ca> wrote:

>You removed /usr/bin/python! This is a really bad idea

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...


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
Apr 11 '06 #17

This discussion thread is closed

Replies have been disabled for this discussion.