How to Add Custom Paths to Python sys.path

September 29, 2011 · 0 comments

in Python

Python looks for .so files in the location specified in sys.path. Sometimes however, these standard paths doesn’t include the .so or library files that you require. In those cases a quick way to add your own location to the list of directories/locations is to create a file name ending in .pth which contains the directory location in each line. The .pth file must be saved in one of the directories already in the path. This might very well be the ...site_packages/ folder.

sample mypath.pth file content:
/usr/lib64/python2.7/lib-dynload

Previous post:

Next post: