sys.path

The list of folders Python searches, in order, when it imports a module.

In more detail

The first entry is the folder of the script that was run, so a file of your own can shadow a standard module. The first match wins. Because sys.path is an ordinary list, a program can append a folder to it before importing from there.

Example

import sys
sys.path.append('/opt/libs')
import helper

Related terms

Taught in

References

Certification courses