PYTHONPATH on PC
David Smith
drs at hpl.hp.com
Wed Feb 23 13:20:13 EST 2000
I'm running Python 1.5.2 on a PC and am having trouble getting it to
"import" my modules. I copied fibo.py from the online introduction into
my directory, C:\David and try to import it. Of course, that doesn't
work, because Python is set to come up with C:\Program Files\Python as
the working directory. So I tried
import os
os.chdir('C:\David')
import fibo
and it still can't find fibo. There wasn't a PYTHONPATH environment
variable, so I set it locally:
os.environ['PYTHONPATH'] = r'.;C:\David;C:\Program Files\Python\Lib'
and that didn't work. I have found two ways to get Python to find my
module. One is to put the module directly into C:\Program
Files\Python\Lib, but that is pretty sick. The other is to modify
Idle's shortcut to have it start up in C:\David. But what if I or
someone else wanted to work in a different directory?
And anyway, what is the default path on a PC when there is no PYTHONPATH
environment variable?
David Smith
More information about the Python-list
mailing list