[Tutor] adding a new folder to Python's importable modules search path

tpc247 at gmail.com tpc247 at gmail.com
Mon Nov 26 02:56:04 CET 2007

Dear fellow Python enthusiasts,

I trust your Thanksgiving holiday has been a relaxing one.  A quick question
for you: I have a script that attempts to import my_module from a folder
that is not in Python's importable modules search path.  In my script, that
I run from the command line, I have the following lines:

import os
import sys

PATH_TO_MODULE = os.path.join('path', 'to', 'my', 'module')

import my_module

When I attempt to run the script, I get the following error message:

ImportError: No module named my_module

In Python IDLE when I perform the aforementioned steps in the order
indicated I can import my_module successfully.  My assumption is Python's
importable modules search path is in sys.path.  In both cases I identify the
path to the folder containing my module, I append said path to sys.path, and
when I attempt to import my_module by either running from the command line
or in IDLE, I get different behavior.  I read the information here again:


so I believe I am doing everything correctly.  Am I doing something wrong ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071125/4a255c9d/attachment.htm 

More information about the Tutor mailing list