PYTHONPATH on Mac 10.5

Python Nutter pythonnutter at gmail.com
Thu Feb 26 02:09:05 EST 2009


+1 for site packages and standard shebang, still lets you launch with
python first followed by .py file or <big long path to a specific
python> followed by .py file

also for some clues, just open up a terminal in your Mac OS X computer
and check out your exports your PATH will be different depending on
all the software and development environments you may or may not be
using on your Mac, in particular:

declare -x PATH="/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"

declare -x PYTHONSTARTUP="/Users/pythonnutter/.pythonstartup"

for the ultra curious, my custom python startup:

$cat .pythonstartup
# python startup file
import readline
import rlcompleter
import atexit
import os
# tab completion
readline.parse_and_bind('tab: complete')
# history file
histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
try:
    readline.read_history_file(histfile)
except IOError:
    pass
atexit.register(readline.write_history_file, histfile)
del os, histfile, readline, rlcompleter



On Windows you don't have much control in standard batch files but the
way I keep my Windows box (at work mind you, none at home)
multi-python'd

is I configure the environment for Framework 2.5.4, and all the path
environment variables are configured for the standard directory and
the scripts subdirectory.

in 25's scripts is go26.bat which just pre-pends the 2.6.1 path on the
head of PATH, and of course a go3.bat that pre-pends in 3.0.1

if you want to get fancy, since there is no pop in batch files that I
know of, you could drop a .py script in to read in PATH, pop off two
entries and modify the environment PATH so you fall back down the tree
(might need some list reversing in there to finish the massaging for
pops)

most times I get by with just exiting the terminal session in windows
and a new cmd session will once again take on the defaults for 2.5.4



More information about the Python-list mailing list