how does Python know where to look for the modules and packages that are imported? The built-in
sys module has a list called
sys.path that holds a list of the directories that constitute the Python path. The first directory is the directory that contains the program itself, even if the program was invoked from another directory. If the
PYTHONPATH environment variable is set, the paths specified in it are the next ones in the list, and the final paths are those needed to access Python’s standard library—these are set when Python is installed.
- 5. Modules
- from Programming in Python 3: A Complete Introduction to the Python Language, Second Edition
- Publisher: Addison-Wesley Professional
- Released: November 2009
use sys.path to know where Python looks for libs. Use PYTHONPATH to define own path.
Share this highlighthttp://www.safaribooksonline.com/a/programming-in-python/9045024/