1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
5 <meta http-equiv=
"content-type" content=
"text/html; charset=iso-8859-1">
6 <title>Python and the Unix Shell
</title>
7 <meta name=
"generator" content=
"BBEdit 6.5.3">
8 <link rel=
"SHORTCUT ICON" href=
"pythonsmall.gif">
9 <META NAME=
"AppleIcon" CONTENT=
"pythonsmall.gif">
12 <h1>Running Python scripts from the Unix Shell
</h1>
16 <img src=
"python.gif" width=
"128" height=
"128" align=
"top" alt=
"">
19 <p>MacPython
2.3 installs a perfectly normal Unix commandline
20 python interpreter in
<tt>/usr/local/bin/python
</tt>. As of Mac OS X
10.2, however,
21 <tt>/usr/local/bin
</tt> is not on the search path of your shell. Moreover,
22 Apple's python
2.2, which lives in
<tt>/usr/bin
</tt> <em>is
</em> on your
23 search path, so this can lead to confusion.
</p>
25 <p>If you use
<tt>tcsh
</tt> you should add the following line
26 to the file
<tt>.login
</tt> in your home directory and restart Terminal:
28 <tt>setenv PATH /usr/local/bin:$PATH
</tt>
31 <p>If you use
<tt>bash
</tt> or
<tt>zsh
</tt>
32 you should add the following line
33 to the file
<tt>.profile
</tt> in your home directory and restart Terminal:
35 <tt>export PATH=/usr/local/bin:$PATH
</tt>
40 <p>Due to the way MacOS handles windowing applications you need to run
41 <em>all
</em> scripts that use the window manager (be it through
42 Carbon, Cocoa, Tkinter, wxPython, PyOpenGL or anything else) with the
43 <tt>pythonw
</tt> interpreter, also installed in
<tt>/usr/local/bin
</tt>.
</p>
45 <p>Running with
<tt>python
</tt> results in an inability to bring the
46 script to the front, or interacting with it.
</p>