Of course! Here are several ways to print the Python path, explained from the simplest to the most detailed.

The Short Answer (Most Common)
This command prints the list of directories where Python looks for modules and packages. It's the most direct answer to your question.
import sys print(sys.path)
Detailed Explanation and Other Methods
Here’s a breakdown of what the Python path is and how to view it in different contexts.
What is the Python Path?
The "Python path" (more accurately, the sys.path list) is an ordered list of directory paths. When you write import my_module, Python searches for my_module.py (or a package named my_module) in each of these directories, in the order they appear.
The default paths typically include:

- The directory containing the script you are running.
- Standard library directories (e.g.,
.../lib/python3.9/). - Site-packages directories (where
pipinstalls third-party packages). - Directories listed in the
PYTHONPATHenvironment variable (if set).
Method 1: Using the sys Module (Recommended)
This is the standard, programmatic way to access the path from within a Python script.
import sys # Print the path as a list of strings print(sys.path)
Example Output:
['/home/user/my_project',
'/usr/lib/python39.zip',
'/usr/lib/python3.9',
'/usr/lib/python3.9/lib-dynload',
'/home/user/.local/lib/python3.9/site-packages',
'/usr/lib/python3.9/site-packages']
You can also print each path on a new line for better readability:
import sys
print("Python Path:")
for path in sys.path:
print(path)
Method 2: Using the os Module to Show PYTHONPATH
This method is useful if you want to see the PYTHONPATH environment variable, which is one of the components that contributes to sys.path.

import os
# Print the value of the PYTHONPATH environment variable
# It will be None if it's not set.
print(os.environ.get('PYTHONPATH'))
Example Output (if PYTHONPATH is set):
/path/to/my/custom_lib:/another/path
Example Output (if PYTHONPATH is not set):
None
Method 3: From the Command Line (Without a Script)
Sometimes you want to check the path without writing or running a Python file.
a) Using the -c flag
This is the most direct command-line equivalent.
python -c "import sys; print(sys.path)"
b) Using the site module
The site module is responsible for handling the user site-packages directory and can also show you the paths.
python -m site --user-site
This command specifically prints the path for user-installed packages, which is often very useful.
To see all the paths that the site module processes, you can use:
python -c "import site; print(site.getsitepackages())"
This will print a list of system-wide package directories (like site-packages).
Method 4: Using an Interactive Python Shell
You can also check the path interactively.
- Open your terminal or command prompt.
- Start the Python interpreter by typing
pythonorpython3. - Run the import and print commands directly.
$ python Python 3.9.7 (default, Sep 10 2025, 14:59:43) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/home/user/.local/lib/python3.9/site-packages', '/usr/lib/python3.9/site-packages'] >>>
(Note: The empty string at the beginning represents the current working directory.)
Summary: Which Method to Use?
| Method | When to Use It |
|---|---|
import sys; print(sys.path) |
Most of the time. This is the standard, most reliable way to see the full module search path. |
python -c "import sys; print(sys.path)" |
Quickly check the path from your terminal without creating a script file. |
import os; print(os.environ.get('PYTHONPATH')) |
When you specifically want to see the value of the PYTHONPATH environment variable. |
python -m site --user-site |
When you're only interested in the directory where pip install --user puts packages. |
