The Module Search Path

When loading modules, the interpreter searches the list of directories in sys.path. The following is a typical value of sys.path:

['', '/usr/local/lib/python2.0', 
     '/usr/local/lib/python2.0/plat-sunos5', 
     '/usr/local/lib/python2.0/lib-tk', 
     '/usr/local/lib/python2.0/lib-dynload', 
     '/usr/local/lib/python2.0/site-packages'] 

The empty string '' refers to the current directory.

To add new directories to the search path, simply append them to this list.

Get Python Essential Reference, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.