[Tutor] Is it possible to add PYTHONPATHS recursively?

Kent Johnson kent_johnson at skillsoft.com
Tue Aug 3 20:32:39 CEST 2004

You could do this programmatically in sitecustomize.py:
- Put a module named sitecustomize.py in your Python/Lib directory

- Make whatever changes you want to sys.path in this module, e.g.
import sys
sys.path.append(<path to my directory>)

(Use os.walk() to traverse a directory tree)

- sitecustomize.py will be executed every time the interpreter starts

I'm not sure it's a good idea to append every subfolder of site-packages, 
since some packages will have subpackages  (in folders) that shouldn't 
become top-level packages. You might want to have a single subfolder of 
site-packages that you put your folders in. Then in sitecustomize.py you 
would recursively traverse that folder.


At 06:01 PM 8/3/2004 +0200, Klas Marteleur wrote:
>Hi again
>Is it possible to add PYTHONPATHS recursively, so that every subfolder 
>will be
>Now i am creating .pth files under site-packages.
>Tutor maillist  -  Tutor at python.org

More information about the Tutor mailing list