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
๐ŸŒ
Quora
quora.com โ€บ How-do-I-find-a-Python-path-in-Linux
How to find a Python path in Linux - Quora
Answer (1 of 5): This works with every executable - use the which command [code]$> which python3.9 [/code]If you are able to use the command โ€˜python3.9โ€™ at the command line then the โ€˜whichโ€™ command above will tell you the path to that command. If you need to find the path from within ...
People also ask

Is PYTHONPATH required to import installed packages?
Python adds applicable package locations through its normal initialization. If an installed package cannot be imported, identify the active interpreter before adding extra paths.
๐ŸŒ
askpython.com
askpython.com โ€บ python โ€บ built-in-methods โ€บ pythonpath-in-shell
How to Get the Pythonpath in Shell? - AskPython
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
๐ŸŒ
AskPython
askpython.com โ€บ python โ€บ built-in-methods โ€บ pythonpath-in-shell
How to Get the Pythonpath in Shell? - AskPython
4 weeks ago - You do not need to copy Pythonโ€™s standard-library or site-packages directories into PYTHONPATH. In Bash on Linux or macOS, print the variable with printf, keeping its value together through quoting and accepting an unset variable through parameter expansion.
๐ŸŒ
GitHub
bic-berkeley.github.io โ€บ psych-214-fall-2016 โ€บ using_pythonpath.html
Using PYTHONPATH โ€” Functional MRI methods
If you want your IPython sessions to see this new PYTHONPATH variable, youโ€™ll have to restart your terminal and restart IPython so that it picks up PYTHONPATH from the environment settings. You can check the current setting of environment variables, using the os.environ dictionary.
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ python-how-to-check-the-python-system-path-to-find-necessary-modules-397953
How to check the Python system path to find necessary modules | LabEx
Setting PYTHONPATH in the terminal using export only affects the current terminal session. To make the change permanent, you would typically add the export command to your shell's startup file (e.g., ~/.bashrc, ~/.zshrc). However, for this lab, setting it in the current session is sufficient to demonstrate the concept. In this lab, you have learned how to check and modify the Python system path (sys.path).
Find elsewhere
๐ŸŒ
YouTube
youtube.com โ€บ codemint
check python path ubuntu - YouTube
Instantly Download or Run the code at https://codegive.com tutorial: checking python path in ubuntuin ubuntu, checking the python path can be essential for ...
Published: March 16, 2024
Views: 59
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to find python path in cmd - YouTube
find python path command line linuxpython location commandfind python install location windows 10find python path macfind python path ubuntucheck python path...
Published: June 27, 2023
๐ŸŒ
Net Informations
net-informations.com โ€บ python โ€บ intro โ€บ path.htm
How to set python path
bash shell (Linux): type export ATH="$PATH:/usr/local/bin/python" and press Enter. sh or ksh shell: type PATH="$PATH:/usr/local/bin/python" and press Enter. /usr/local/bin/python is the default path of the Python directory. PYTHONPATH functions as an environment variable that enables the inclusion ...
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ How-to-set-python-environment-variable-PYTHONPATH-on-Linux
How to set Python environment variable PYTHONPATH on Linux?
May 2, 2023 - The PYTHONPATH environment variable tells Python where to look for modules and packages beyond the standard library. Setting it correctly on Linux ensures your custom modules can be imported from any location.
๐ŸŒ
Iditect
iditect.com โ€บ faq โ€บ python โ€บ pythonpath-on-linux.html
PYTHONPATH on Linux
# Check PYTHONPATH to ensure it has the expected directories echo $PYTHONPATH # Check if a directory exists ls /path/to/expected/module # Test importing a module python -c 'import my_module' # If it fails, there may be an issue with PYTHONPATH ยท Finding Python's Default Module Search Paths on Linux
๐ŸŒ
Redreamality
redreamality.com โ€บ blog โ€บ pythonpathvs-code
How to Set PYTHONPATH on Windows, Linux, macOS and VS Code
August 21, 2025 - Additionally, you can check sys.path in the Python interpreter, which is a list of all module search paths. The directories specified in PYTHONPATH should appear in this list. ... Separator: Windows uses a semicolon (;), while macOS and Linux use a colon (:).
๐ŸŒ
Simplilearn
simplilearn.com โ€บ home โ€บ resources โ€บ software development โ€บ understanding the python path environment variable in python
Understanding the Python Path Environment Variable in Python [Updated]
September 14, 2025 - Python path is an environment variable used to maintain directories of custom Python libraries. Learn how to set a python path variable on Windows and Mac now!
Address: 5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
๐ŸŒ
Linux Mint Forums
forums.linuxmint.com โ€บ board index โ€บ main edition support โ€บ beginner questions
Python PATH - Linux Mint Forums
PYTHONPATH is much less generic, since Python-interpreter specific, and serves a moreover very different purpose: it only provides the Python interpreter with a list of locations to search for imported modules, not the system with one to search for (Python) script/applications itself.
๐ŸŒ
CodeGenes
codegenes.net โ€บ blog โ€บ how-to-check-python-path
How to Check Python Path โ€” codegenes.net
On some systems, you can check the Python path from the command line without starting the Python interpreter. For example, on Linux and macOS, you can use the following command:
Top answer
1 of 4
5

I'm assuming that when you installed anaconda 2, you manually set the PYTHONPATH environment variable, by putting something like

PYTHONPATH=/home/user/anaconda2/python
export PYTHONPATH

in your .bash_profile or .bash_rc.

But since you deleted the /home/user/anacanda2/ directory, that path no longer exists.

Thus you want to change PYTHONPATH to point to the executable in /usr/lib, by changing the above to

PYTHONPATH=/usr/lib/my_python_distribution
export PYTHON
2 of 4
3
  1. execute the command: echo $PATH

    root1@master:/usr/lib/python2.7$ echo $PATH
    /home/root1/anaconda3/bin:/home/root1/NAI/Execution/HDE/x86_64.linux/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/root1/java/jdk1.8.0_74/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/root1/NAI/hadoop-2.7.3/bin
    
  2. Remove your anaconda3 from your path variable that is

    /home/root1/anaconda3/bin:
    
  3. Again set PATH variable with remaining information like below

    export PATH=/home/root1/NAI/Execution/HDE/x86_64.linux/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/root1/java/jdk1.8.0_74/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/root1/NAI/hadoop-2.7.3/bin
    
  4. Execute python command and should redirect to your python interpreter

    root1@master:/usr/lib/python2.7$ python
    Python 2.7.14 (default, Sep 18 2017, 00:00:00) 
    [GCC 4.8.4] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>