Problems with import of modules

Carl J. Van Arsdall cvanarsdall at
Mon Jan 23 14:10:37 EST 2006

Ilias Lazaridis wrote:
> I am within a directory
> \doc\template\
> I launch
> within this, I like to import a module from the doc directory.
> this here does not work:
> form ..\..\module_name import this_one
Well, if you are in linux you can do this easily by changing your 
PYTHONPATH environment variable, either by changing it explicitely or by 
editing it in your .rc files to append the /doc directory.

Although I don't know specifically where this variable might be if you 
are using windows, in either case(windows or linux), you can alter this 
from python using sys.path

import sys

Hope that helps,


> how do I go back in the directory hierarchy to import something?
> If this is not possible:
> How can I modify the python search-path from within the script, thus it 
> contains the doc directory?
> .


Carl J. Van Arsdall
cvanarsdall at
Build and Release
MontaVista Software

More information about the Python-list mailing list