[Tutor] HOWTO: adding to sys.path the simplest way.

Kent Johnson kent37 at tds.net
Fri Aug 24 04:49:35 CEST 2007


Tim Johnson wrote:
> I have a seperate library directory both on my work station on
> the the remote servers that I write applications for..
> 
> I commonly use sys.path.append('/path/to/mylibraries') in my 
> python code.
> 
> That code has to be placed in any standalone script that I write.
> I can also place that path in a system file. On my kubuntu
> workstation, it is /var/lib/python-support/python2.5/.path
> 
> I believe that path is different on the solaris or redhat servers
> that I provide scripts to. Furthermore, any update of the python version
> will necessitate editing of the new .path file.
> 
> I would welcome some opinions on this matter.

Make a file called mylibraries.pth with contents
/path/to/mylibraries

Put the file in your site-packages folder (I don't know wherethat is for 
you).

Updating Python will still require copying the .pth file to the new 
site-packages folder but no editing.

Or you could just put the libraries in site-packages directly.

Kent


More information about the Tutor mailing list