I am running Mac OS X 10.5.8. I have installed Python 2.6 from the site. It\'s in my application directory. I have edited my .bash_profile to have:
# Sett
Seems to be a common problem:
http://www.google.com/search?q=python+idle+pythonpath
Unfortunately, no answers. The only suggestion seemed to be to edit the idle
executable and adding a few sys.path.insert(...)
lines.
Like all OS X application bundles, if you launch IDLE.app
by double-clicking, a shell is not involved and thus .bash_profile
or other shell initialization files are not invoked. There is a way to set user session environment variables through the use of a special property list file (~/.MacOSX/environment.plist
) but it really is a bit of a kludge and not recommended.
Fortunately, there is a simpler solution: on OS X, it is also possible to invoke IDLE
from a shell command line in a terminal window. In this way, it will inherit exported environment variables from that shell as you would expect. So something like:
$ export PYTHONPATH= ...
$ /usr/local/bin/idle2.6
There were various inconsistencies and problems with IDLE on OS X prior to 2.6.2 depending on how it was invoked so I recommend using nothing older than the python.org 2.6.2 or 3.1 versions on OS X.
EDIT: I see from the open(1)
man page that, since 10.4, applications launched via open
also inherit environment variables so that would work from the command line as well. If you want to avoid opening a terminal window, it is easy to create a simple launcher app using AppleScript or Automator (or even Python with py2app!). In this case, use the open command command so that the launcher app does not sit around. For example, in Automator, choose the Run Shell Script
action and add:
export PYTHONPATH= ...
open -a "/Applications/Python 2.6/IDLE.app"
Save it as File Format Application
(in 10.5) and you should have a clickable way to launch a tailored IDLE.