Sitemap
Bryant Jimin Son

Bryant Jimin Son

A cloud practitioner talking about technology, travels & career tips. But I will sometimes cover financial advises and some random stuffs.

Member-only story

Use of “PYTHONPATH” for Python setup

5 min readJan 26, 2026

--

PYTHONPATH

PYTHONPATH is an environment variable that affects Python’s module and package search path. It allows you to configure additional directories that the Python interpreter will search when processing import statements.

In other words, it is one of the key mechanisms for controlling where Python looks when importing modules.

Python Module and Package Search Path

1. Default Search Path

When the Python interpreter starts, it internally initializes a list called sys.path.

Typically, sys.path includes the following paths:

  • The current working directory (or the directory containing the script)
  • Standard library paths (e.g., /usr/lib/python3.9, C:\Python39\Lib)
  • site-packages (where third-party packages are installed)
  • Paths specified in the PYTHONPATH environment variable (if any)

2. Relationship Between PYTHONPATH and sys.path

When Python starts, directories defined in PYTHONPATH are inserted into sys.path (usually near the beginning).

This allows Python to search those directories before the standard library, increasing their priority, or to include project-specific library directories in the import path.

3. Import Resolution Behavior

--

--

Bryant Jimin Son
Bryant Jimin Son

Written by Bryant Jimin Son

A cloud practitioner talking about technology, travels & career tips. But I will sometimes cover financial advises and some random stuffs.