idle import problem
mwilson at sarcastic-horse.com
Tue Sep 23 21:03:01 CEST 2003
That's really useful. I know how to set PYTHONPATH in unix, but how to in
> On Tuesday 23 Sep 2003 5:43 pm, Matthew Wilson wrote:
>> I'm trying to import a countylist.py file in idle, and it isn't working.
>> What am I doing wrong?
>> >>> os.listdir(os.getcwd())
>> ['4dcountylist.txt', 'CBP90KY_TXT.htm', 'CBP90OH_TXT.htm',
>> 'CBP90PA_TXT.htm', 'CBP90WV_TXT.htm', 'countylist.py', 'geocode.txt',
>> 'mvsales.xls', 'mvsalesbyfirm.xls', 'production_in_4d.xls',
>> >>> import countylist
>> Traceback (most recent call last):
>> File "<pyshell#15>", line 1, in -toplevel-
>> import countylist
>> ImportError: No module named countylist
>> Any ideas?
> Python doesn't import from the current directory; it uses sys.path, unless
> cwd is on sys.path...
> if you want to temporarily put it on the path, do:
> import os,sys
> but a better solution is to either put your module into a directory tha
> on sys.path, or modify your python path setting directlty by setting your
> environment var PYTHONPATH accordingly.
> hope that helps
More information about the Python-list