The environment variable PYTHONPATH is actually only added to the list of locations Python searches for modules. You can print out the full list in the terminal like this:

python -c "import sys; print(sys.path)"

Or if want the output in the UNIX directory list style (separated by :) you can do this:

python -c "import sys; print(':'.join(x for x in sys.path if x))"

Which will output something like this:

/usr/local/lib/python2.7/dist-packages/feedparser-5.1.3-py2.7.egg:/usr/local/lib/
python2.7/dist-packages/stripogram-1.5-py2.7.egg:/home/qiime/lib:/home/debian:/us
r/lib/python2.7:/usr/lib/python2.7/plat-linux2:/usr/lib/python2.7/lib-tk:/usr/lib
/python2.7/lib-old:/usr/lib/python2.7/lib- dynload:/usr/local/lib/python2.7/dist-
packages:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages/PIL:/u
sr/lib/python2.7/dist-packages/gst-0.10:/usr/lib/python2.7/dist-packages/gtk-2.0:
/usr/lib/pymodules/python2.7
Answer from Hubro on Stack Overflow
Discussions

scripting - echo $PATH shows path to python scripts, but they cannot be executed - Unix & Linux Stack Exchange
I am new to using the shell, and wanted to create a directory in $HOME where I can put all my python scripts, set a path to that directory, so that I can go into any folder on my Mac and execute th... More on unix.stackexchange.com
🌐 unix.stackexchange.com
February 13, 2016
debian - $PYTHONPATH and sys.path don't seems to match - Unix & Linux Stack Exchange
I want to add a folder permanently to sys.path but it doesn't work. On my Debian Stretch, when I execute : $ echo $PYTHONPATH it looks empty In the same time, when I print the content of sys.p... More on unix.stackexchange.com
🌐 unix.stackexchange.com
python - How to add to the PYTHONPATH in Windows, so it finds my modules/packages? - Stack Overflow
To set the PYTHONPATH permanently, add the line to your autoexec.bat. Alternatively, if you edit the system variable through the System Properties, it will also be changed permanently. ... Dos and editing autoexec.bat..! Have we suddenly slipped back into the 90s? 2013-12-12T18:05:38.373Z+00:00 ... Before this, do echo ... More on stackoverflow.com
🌐 stackoverflow.com
sys.path and pythonpath
There's site-specific (i.e. python environment/install specific) things that happen as well: https://docs.python.org/2/library/site.html#module-site This module is automatically imported during initialization. The automatic import can be suppressed using the interpreter’s -S option. Importing this module will append site-specific paths to the module search path and add a few builtins. This interacts with the values in sys.prefixand sys.exec_prefixthat were set at compile-time for where to look for site-specific modules. There's also some stuff about enabling user-specific modules so that individual users on multi-user systems can have different sets of modules available to them. More on reddit.com
🌐 r/learnpython
3
5
December 15, 2016
People also ask

How do I add PYTHONPATH inside a Python script?
Changing os.environ["PYTHONPATH"] changes the process environment and can affect child processes started afterwards. For an import in the running interpreter, add the intended directory to sys.path before importing, or install the package into that interpreter’s environment.
🌐
askpython.com
askpython.com › python › built-in-methods › pythonpath-in-shell
How to Get the Pythonpath in Shell? - AskPython
Does a virtual environment ignore PYTHONPATH?
A virtual environment can inherit PYTHONPATH from the shell that launches it. That extra search location can expose code outside the environment, so remove unintended overrides when diagnosing imports.
🌐
askpython.com
askpython.com › python › built-in-methods › pythonpath-in-shell
How to Get the Pythonpath in Shell? - AskPython
How do I set multiple directories in PYTHONPATH?
Join directory paths with the operating system’s separator. It is a colon on Linux and macOS and a semicolon on Windows, and os.pathsep reports the appropriate character.
🌐
askpython.com
askpython.com › python › built-in-methods › pythonpath-in-shell
How to Get the Pythonpath in Shell? - AskPython
🌐
AskPython
askpython.com › python › built-in-methods › pythonpath-in-shell
How to Get the Pythonpath in Shell? - AskPython
3 weeks ago - For a file launched as a script, the normal first entry is that script’s directory, rather than an empty string. PYTHONPATH supplements this initialization, so its text cannot reproduce the entire sys.path list.
🌐
Redreamality
redreamality.com › blog › pythonpathvs-code
How to Set PYTHONPATH on Windows, Linux, macOS and VS Code
August 21, 2025 - To check if PYTHONPATH has been set correctly, you can execute the following in your terminal or command prompt: In Windows (cmd.exe): echo %PYTHONPATH% In Windows (PowerShell): $env:PYTHONPATH · In macOS and Linux: echo $PYTHONPATH · ...
🌐
Linux Mint Forums
forums.linuxmint.com › board index › main edition support › beginner questions
no $PYTHONPATH environment variable? - Linux Mint Forums
September 4, 2013 - Add the line "PYTHONPATH=/usr/bin/python" to the file (don't use quotes). Save, logout, login again and it will be there. One other thing, you can add "#!/usr/bin/python" (don't use quotes) to the top line of any file if you want it to execute using python. ... I did as instructed and "echo ...
Find elsewhere
🌐
Uchicago
geosci.uchicago.edu › ~rtp1 › PrinciplesPlanetaryClimate › Python › ShellsNStuff.html
About Shells, Paths and Environment Variables
echo $SHELL · In sh and bash, you set the environment variable using the command · export PYTHONPATH=/Users/frodo/MyModules ·
🌐
Super User
superuser.com › questions › 917675 › pythonpath-variable-cant-be-echoed-by-non-root
linux - PYTHONPATH variable can't be echoed by non-root - Super User
I added Defaults env_keep += "PYTHONPATH" to the sudoers file. Then from root, I echoed PYTHONPATH as echo $PYTHONPATH and it echoed successfully.
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-set-python-environment-variable-pythonpath-on-linux
How to set Python environment variable PYTHONPATH on Linux?
March 24, 2026 - ... The export command only affects the current terminal session. For permanent setup, add the export command to your shell configuration file ? echo 'export PYTHONPATH=$PYTHONPATH:~/my_module' ...
🌐
Jss367
jss367.github.io › path-problems-windows.html
Path Problems: Windows | Julius’ Data Science Blog
January 31, 2020 - On Windows, if you echo $PYTHONPATH you get nothing, but you can use Python to see what’s in your path
🌐
Real Python
realpython.com › add-python-to-path
How to Add Python to PATH – Real Python
July 23, 2026 - $ echo $PATH | tr ":" "\n" /usr/local/sbin /usr/local/bin /usr/sbin /home/realpython/badpython /usr/bin /sbin /bin /usr/games /usr/local/games
🌐
LinuxQuestions.org
linuxquestions.org › questions › linux-newbie-8 › what-on-earth-is-$pythonpath-4175574196
[SOLVED] What on earth is $PYTHONPATH
March 7, 2016 - Sorry for all these questions guys... But I've been trying to make sense of this statement for several days. Add the module directory to your PYTHONPA
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 4625549705234-Why-is-PYTHONPATH-empty-and-must-be-exported-every-terminal-session
Why is PYTHONPATH empty and must be exported every terminal session? – IDEs Support (IntelliJ Platform) | JetBrains
March 12, 2022 - Hi 😊 Using Mac OS - Big Sur, I have a PyCharm project that holds two source roots directories.Whenever I try to: echo $PYTHONPATH It results empty and I must export it locally per session.I am usin...
🌐
Reddit
reddit.com › r/learnpython › sys.path and pythonpath
r/learnpython on Reddit: sys.path and pythonpath
December 15, 2016 -

As per the documents:

A list of strings that specifies the search path for modules. Initialized from the environment variable PYTHONPATH, plus an installation-dependent default.

As initialized upon program startup, the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter. If the script directory is not available (e.g. if the interpreter is invoked interactively or if the script is read from standard input), path[0] is the empty string, which directs Python to search modules in the current directory first. Notice that the script directory is inserted before the entries inserted as a result of PYTHONPATH.

A program is free to modify this list for its own purposes.

So sys.path is basically the path of the current directory and the paths resulting from the PYTHONPATH environmental variable.

If I open up the python repl, sys.path outputs:

['', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload', '/home/mike/.local/lib/python3.4/site-packages', '/usr/local/lib/python3.4/dist-packages', '/usr/lib/python3/dist-packages']

However, if I echo PYTHONPATH on the commandline:

echo $PYTHONPATH

Nothing outputs. If the PYTHONPATH environmental variable isn't set then how does python know which paths to use?