You would probably also want this:

import sys
print(sys.path)

Or as a one liner from the terminal:

python -c "import sys; print('\n'.join(sys.path))"

Caveat: If you have multiple versions of Python installed you should use a corresponding command python2 or python3.

Answer from Vanuan on Stack Overflow
🌐
AskPython
askpython.com › python › built-in-methods › pythonpath-in-shell
How to Get the Pythonpath in Shell? - AskPython
3 weeks ago - I got None with PYTHONPATH unset, while an explicitly empty value produced an empty string. To read the value without the redundant assignment, use the shorter command below. Testing membership in os.environ distinguishes an absent variable from one that exists with an empty value. python3 -c "import os; print(os.getenv('PYTHONPATH'))" python3 -c "import os; print('PYTHONPATH' in os.environ)"
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
What is Pythonpath used for?
Pythonpath is an environment variable that is used to specify the location of Python libraries. It is typically used by developers to ensure that their code can find the required Python libraries when it is run.
🌐
simplilearn.com
simplilearn.com › home › resources › software development › understanding the python path environment variable in python
Understanding the Python Path Environment Variable in Python [Updated]
🌐
GitHub
bic-berkeley.github.io › psych-214-fall-2016 › using_pythonpath.html
Using PYTHONPATH — Functional MRI methods
The PYTHONPATH variable has a value that is a string with a list of directories that Python should add to the sys.path directory list.
🌐
GitHub
gist.github.com › bngsudheer › 8b84b2e4dd5440333621e603104ccf6c
Print $PYTHONPATH · GitHub
Print $PYTHONPATH · Raw · print-python-path.py · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters ·
Find elsewhere
🌐
Python.org
discuss.python.org › python help
Usage of PYTHONPATH - Python Help - Discussions on Python.org
August 9, 2022 - The results of my research are ... values: C:\Program Files\Python\DLLs C:\Program Files\Python\Lib C:\Program Files\Python C:\Program Files\Python\Lib\site-packages C:\Users\…\AppData\Roaming\Python\Python310\site-packages I created ...
🌐
Reddit
reddit.com › r/learnpython › quick question: how do i view python's location in command prompt?
r/learnpython on Reddit: Quick Question: How do I view Python's location in command prompt?
November 11, 2021 -

So I've been having trouble with Python and I want to know which installation I'm using (I have two user profiles on Windows, my old one and the one I made explicitly to code in, and they both have Python installed).

I tried looking it up, but it only led to this madness you see below:

    Microsoft Windows [Version 10.0.19043.1348]
    (c) Microsoft Corporation. All rights reserved.

    C:\Users\willi>!type python
    '!type' is not recognized as an internal or external command,
    operable program or batch file.

    C:\Users\willi>type python
    The system cannot find the file specified.

    C:\Users\willi>type Python
    The system cannot find the file specified.

    C:\Users\willi>Python type
    Python: can't open file 'C:\Users\willi\type': [Errno 2] No such file or     directory

    C:\Users\willi>Python
    Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit     (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> python
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    NameError: name 'python' is not defined
    >>> .quit
      File "<stdin>", line 1
        .quit
        ^
    SyntaxError: invalid syntax
    >>> quit
    Use quit() or Ctrl-Z plus Return to exit
    >>> quit()
    
    C:\Users\willi>python
    Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit     (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> !type Python
      File "<stdin>", line 1
        !type Python
        ^
    SyntaxError: invalid syntax
    >>> type
    <class 'type'>
    >>> type python
      File "<stdin>", line 1
        type python
         ^
    SyntaxError: invalid syntax
    >>> type Python
      File "<stdin>", line 1
        type Python
         ^
    SyntaxError: invalid syntax
    >>> type(Python)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    NameError: name 'Python' is not defined
    >>>

How do I view Python's location in command prompt?

🌐
Redreamality
redreamality.com › blog › pythonpathvs-code
How to Set PYTHONPATH on Windows, Linux, macOS and VS Code
August 21, 2025 - PYTHONPATH is an environment variable that allows users to add extra directories to the list of paths that the Python interpreter searches for modules and packages. This is particularly useful during development when you need to import custom modules that are not located in the standard library path or in the installed package directories.
🌐
CodeWithHarry
codewithharry.com › blogpost › how-to-find-python-installation-path
How to find the Python Installation Path on Windows? | Blog | CodeWithHarry
The terminal is a powerful scripting environment and newer command-line shell, offering a more modern approach to interacting with your system. If you use the terminal, the following steps will help you find where Python is installed!
🌐
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
🌐
Codemia
codemia.io › home › knowledge hub › how do i find out my pythonpath using python?
How do I find out my PYTHONPATH using Python? | Codemia
September 23, 2025 - Python does not require PYTHONPATH to exist. The interpreter builds a final search list at startup. That final list is stored in sys.path. python · 1import sys 2 3for entry in sys.path: 4 print(entry) This output usually includes the current script directory, site-packages locations, standard library directories, and any paths injected from PYTHONPATH.
🌐
GeeksforGeeks
geeksforgeeks.org › python › pythonpath-environment-variable-in-python
PYTHONPATH Environment Variable in Python - GeeksforGeeks
January 9, 2026 - PYTHONPATH is an environment variable that tells Python where to look for modules and packages beyond the standard library and installed site-packages. It allows you to import user-defined or non-installed modules directly in your scripts, making it especially useful during development. ... # user-defined module # saved as my_module.py def module_func(): print("You just imported the user-defined module")
🌐
Dummies
dummies.com › article › technology › programming-web-design › python › how-to-find-path-information-in-python-148336
How to Find Path Information in Python | dummies
December 28, 2021 - You see the Python Shell window appear. Type import sys and press Enter. Type for p in sys.path: print(p) in a new cell and click Run Cell
Author:
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › programming › python
How to get Python to use a custom library path - Raspberry Pi Forums
July 2, 2024 - I now to the same thing on the terminal to the right, but use python 3.11 this time, import sys and print sys.path. Notice how there are the same NUMBER of items in the path. Both contain "" (which is the local folder) and "/xxxxxxxxx/dist-packages" (yellow arrows). The other items (green arrows) in the path are specific to each of the different versions of the python interpreter being used. I exit python on both sides. On the left, python3.10, I know add "/foo/bar" to PYTHONPATH.
🌐
GeeksforGeeks
geeksforgeeks.org › python › sys-path-in-python
sys.path in Python - GeeksforGeeks
August 21, 2024 - Python · # importing module import sys # printing all directories for # interpreter to search sys.path · Output: THROUGH ENVIRONMENT VARIABLES- An environment variable that contains the path an interpreter can take while looking for modules can be employed. Once set, it hints interpreter with directories to locate a module. The following example shows how this can be done. PYTHONPATH=C:\Users\Vanshi\Desktop ·
🌐
Real Python
realpython.com › add-python-to-path
How to Add Python to PATH – Real Python
July 23, 2026 - A common fix for these problems is adding Python to the PATH environment variable. In this tutorial, you’ll learn how to add Python to PATH.
🌐
TutorialsPoint
tutorialspoint.com › what-is-pythonpath-environment-variable-in-python
What is PYTHONPATH environment variable in Python?
August 26, 2023 - PYTHONPATH is an environment variable that extends Python's module search path.