liveBook · Manning

Sys.path

sys.path is the ordered sequence of filesystem paths that Python’s import system searches when locating importable modules and packages.

How 3 Manning books explain it

Python Workout: 50 ten-minute exercises

sys.path is the Python list of directory path strings searched by the import system for modules and packages.

How it is used
Explains how import locates modules and packages across configured directories.
How deep it goes
Defines ordered directory lookup and configuration points, stopping short of detailed import-finder internals.
Examples
Uses `import mymod` to demonstrate first-match loading and duplicate-name conflicts.
What you can do after
Diagnose module-resolution conflicts by reasoning from sys.path order and distinguishing lookup from cached loading.

Read how Python Workout: 50 ten-minute exercises explains sys.path →

Python Workout, Second Edition

sys.path is the list of directory names that Python searches when locating importable modules and packages.

How it is used
Resolves module and package names during import, using an ordered list of directories.
How deep it goes
Explains ordered lookup, duplicate-name conflicts, configuration methods, and its boundary with sys.modules.
Examples
Uses os, mymod.py, duplicate module directories, and a mypackage directory containing first.py.
What you can do after
Diagnose import conflicts and configure module discovery through sys.path, PYTHONPATH, or .pth files.

Read how Python Workout, Second Edition explains sys.path →

The Quick Python Book, Fourth Edition

A module search path is the ordered set of directories that a language runtime searches to locate importable modules and packages.

How it is used
Controls where Python finds importable modules and packages during program execution.
How deep it goes
Explains ordered lookup, initialization sources, execution-context differences, and practical configuration options.
Examples
Uses sys.path inspection, a local mymath.py module, shared module directories, and a mymodules.pth file.
What you can do after
Operate/configure Python's module discovery by inspecting sys.path and selecting directory, PYTHONPATH, or .pth placement.

Read how The Quick Python Book, Fourth Edition explains sys.path →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.