O'Reilly logo
  • You Wang thinks this is interesting:

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.

From

Cover of Programming in Python 3: A Complete Introduction to the Python Language, Second Edition

Note

use sys.path to know where Python looks for libs. Use PYTHONPATH to define own path.