← All notes

Python site: site-specific configuration hook

Answer: The site module is imported automatically during interpreter startup.

What it changes

Import of this module usually appends site-specific paths to the module search path.

It also adds callables, including help, to the built-in namespace.

The interpreter S option blocks that automatic import.

Call main to trigger the usual site-specific additions after a suppressed start.

How paths are built

Heads come from sys prefix and sys exec prefix, and empty heads are skipped.

Name pth files contain additional items, one per line, to be appended to sys path.

It builds up to four directories by pairing each head with a tail part.

The colon and callable portion of a start-file entry point are mandatory.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, site — Site-specific configuration hook; CPython, site documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, site — Site-specific configuration hook; CPython, site documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:yxxnn3nz

iinventedlight. 2026. "Python site: site-specific configuration hook." iinventedlight Library, iil:note:yxxnn3nz, version of 2026-11-24. https://iinventedlight.com/library/notes/python-site/. License: CC-BY-4.0.

@misc{iil_note_yxxnn3nz,
  author = {{iinventedlight}},
  title = {{Python site: site-specific configuration hook}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-24},
  url = {https://iinventedlight.com/library/notes/python-site/},
  note = {Permanent ID iil:note:yxxnn3nz. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-site.md.