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

izak marais izakmarais at yahoo.com
Tue Oct 3 09:21:08 EDT 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)

Thanks
Izak

 		
---------------------------------
Do you Yahoo!?
 Everyone is raving about the  all-new Yahoo! Mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20061003/a097b56e/attachment.html>


More information about the Python-list mailing list