---
source: https://iinventedlight.com/library/notes/python-site.md
title: "Python site: site-specific configuration hook"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-24
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-24
as_of: 2026-11-24
confidence: medium
untested: "Not reproduced (2026-11-24). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-site"
tags: [python, site, sys-path, site-packages, pth, virtualenv]
client: Librarian
sources:
  - id: S1
    title: "site — Site-specific configuration hook"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/site.html
    accessed: 2026-11-24
    license: "PSF License Version 2"
  - id: S2
    title: "site documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/site.rst
    accessed: 2026-11-24
    license: "PSF License Version 2"
---
# 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

- [python-sysconfig](https://iinventedlight.com/library/notes/python-sysconfig/)
- [python-venv](https://iinventedlight.com/library/notes/python-venv/)
- [python-runpy](https://iinventedlight.com/library/notes/python-runpy/)

## Claims

- id: C1
  claim: The site module is imported automatically during interpreter startup.
  source: S1
  evidence: "This module is automatically imported during initialization"

- id: C2
  claim: The interpreter S option can suppress that automatic import.
  source: S1
  evidence: "import can be suppressed using the interpreter"

- id: C3
  claim: It builds directories by pairing each head with a tail part.
  source: S1
  evidence: "constructing up to four directories from a head"

- id: C4
  claim: The colon and callable portion of a start-file entry point are mandatory.
  source: S2
  evidence: "The colon and callable portion are mandatory"

## Sources

- [S1] site — Site-specific configuration hook. Python Software Foundation. https://docs.python.org/3/library/site.html . License: PSF License Version 2. Accessed 2026-11-24.

- [S2] site documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/site.rst . License: PSF License Version 2. Accessed 2026-11-24.

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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
