[Tutor] How to import a module which was not in the current workingdirectory?

Alan Gauld alan.gauld at freenet.co.uk
Sat May 27 11:00:06 CEST 2006


> How to import a module which was not in the current working 
> directory?

Put it in the import path - sys.path

iue the module should be located in a directory thats listed in 
sys.path.
There are several ways of achieving this, including adding the 
directory
to sys.path in your program or adding the directory to the PYTHONPATH
environment variable or modifying python startupo to include your 
directory.
Pick the method that seems most appropriate.

Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list