[Tutor] automatically extending PYTHONPATH?

Kent Johnson kent37 at tds.net
Tue Mar 22 00:47:45 CET 2005


You can create a .pth file in site-packages. See these links for details:
http://docs.python.org/inst/search-path.html#SECTION000410000000000000000
http://bob.pythonmac.org/archives/2005/02/06/using-pth-files-for-python-development/

As Liam suggested, you can walk the dir yourself and modify sys.path. The walk code could be in a 
site-customize.py file in site-packages so it will be run automatically every time Python starts up.

Finally, you could put your packages directly in site-packages, then they will always be available.

Kent

Marcus Goldfish wrote:
> I am using Python 2.4/IDLE on WinXP.  I organize my sourcefiles in a
> directory tree, similar to the convention used in Java.  When I create
> a new subdirectory, though, I have to either (i) manually edit my
> PYTHONPATH environment variable, or (ii) do a sys.append() in IDLE for
> the new scripts to be visible.  Is there a workaround for this?  For
> example, is there a setting in IDLE of Python to specify a root source
> directory and have all subdirectories added automatically?
> 
> Hope this makes sense, and that a brilliant mind has a quick solution!
> 
> Thanks,
> Marcus
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 



More information about the Tutor mailing list