Custom Search

Sunday, April 17, 2011

how to add 3rd party python modules (how to modify python search path)

how to add 3rd party python modules
how to modify python search path

1) Use PYTHONPATH environment variables

2) Add symlinks in their site-packages directories.

3) Add directories in their site-packages directories.

4) Another way, is to use *.pth files

The most convenient way [to modify python's search path] is to add a path configuration file to a directory that's already on Python's path, usually to the .../site-packages/ directory. Path configuration files have an extension of .pth, and each line must contain a single path that will be appended to sys.path. (Because the new paths are appended to sys.path, modules in the added directories will not override standard modules. This means you can't use this mechanism for installing fixed versions of standard modules.

No comments:

Post a Comment