[Pythonmac-SIG] Beginner's query: Path configuration in OS X 10.3
Chris Barker
Chris.Barker at noaa.gov
Thu Feb 12 15:57:47 EST 2004
Bob Ippolito wrote:
> On Feb 12, 2004, at 2:54 PM, Jeffrey Dean wrote:
>> I'm running Python 2.3 in Mac OS X 10.3.2
How are you running it?
> files to that directory, so I've put my exercise modules in
>> /Users/Myname/Documents/Python. How the heck do I get Python to look
>> there
>> for modules to import them?
> The site-packages in /System/Library/Frameworks/Python.framework is a
> symlink to /Library/Python/2.3, which should be writable by anyone in
> the admin group.
>
> Python also looks in the Library/Python/2.3/site-packages location
> inside your home folder
As the names indicate, those are good places to put what might be called
a "library" of python modules--ones you want to use use from various
other python scripts.
For just playing around, learning, and developing new code, you probably
want to put the *.py files wherever in your home folder makes sense to you.
What you want to do is make the "working directory", the same as the one
you are , well, working in. Python will look in the working directory
for modules.
I generally run python from the command line in Terminal, so I first cd
to the directory my files are in, then run python. (I found a nifty
script on the web that puts a button on the finder that will launch a
terminal in the directory currently selected, which makes this easy)
If you're using the IDE, I'm pretty sure there is a way to set the
working directory, but I don't recall what it is at the moment. I
abandoned the IDE as soon as OS-X gave me a command line.
You can also set the working directory from within Python with:
os.chdir(path)
I'm kind of a Linux geek, but this seems like the logical way to do
things to me.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the Pythonmac-SIG
mailing list