importing module

Peter Otten __peter__ at web.de
Thu Sep 9 08:51:21 EDT 2010


Holzwarth, Dominique (Berne Branch) wrote:

> Hi all
> 
> Lets assume I have the following structure of directories and python
> modules:
> 
> Root-dir
> |_dir1
>   |_ script1.py
> |_dir2
>   |_ script2.py
>   |_sudir2
>      |_ script3.py
> 
> Is it possible to import script1 into script2 and script3? Or do have to
> put script1.py into the Lib\site-packages folder of my Python installation
> so that it'll be in the standard module search path?

You have three options

- put script1.py into a directory in python's search path
- modify the PYTHONPATH environment variable to include /path/to/dir1
- add a .pth file in a directory already in python's search path

http://docs.python.org/library/site.html#module-site
http://docs.python.org/install/#inst-search-path

Peter



More information about the Python-list mailing list