Newbie question: python doesn't search the cwd for my module

izak marais izakmarais at
Tue Oct 3 15:21:08 CEST 2006

Hello All

I want to import a module I wrote to use it in a script. But, it is not in the same directory as the script I want to import it into. So my solution is to put the following piece of code in the script:

import os
os.chdir(<the direcotry where the module is kept>)
import <the module>

This generates an error: 'ImportError: no module named <the module>'

If I do the exact same code in interactive mode, using ipython it works fine, but when I try it in a script I get the error. I've even used os.listdir() after changing the directory to confirm that the module is in the cwd (and it is).

Where am I going wrong?
(I use windows XP, and enthought edition python2.4)


Do you Yahoo!?
 Everyone is raving about the  all-new Yahoo! Mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list