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 - Python can read the environment inherited from its launching shell with os.getenv. The following command assigns an empty-string fallback to pythonpath but prints a separate lookup without that fallback, so an unset variable prints None.
People also ask

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]
How do I create a Pythonpath variable?
To create a Pythonpath variable, you will need to first open the Command Prompt.  Once the Command Prompt is open, you will need to type in the following command: setx /M Pythonpath "C:\Python27\Lib".  And you should know that creating a Pythonpath environment variable in Python will be changing depending on your operating system and whether you want the variable to be permanent. On Windows, you can use the set command to create a Pythonpath variable:set Pythonpath=C:\python On Mac or Linux, you can use the export command to create a Pythonpath variable:export Pythonpath =/usr/local/lib/python
๐ŸŒ
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
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.
๐ŸŒ
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 - If you donโ€™t see a needed path, you can always check in another place that Python looks for information. The following steps show how to perform this task: In a new cell, type import os and press Enter. Type os.environ['PYTHONPATH'].split...
Author:
๐ŸŒ
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.
๐ŸŒ
W3docs
w3docs.com โ€บ home โ€บ code snippets โ€บ python โ€บ how do i find out my pythonpath using python?
How do I find out my PYTHONPATH using Python? | W3docs
You can use the sys module in Python to access the sys.path variable, which contains a list of directories that Python looks in for modules to import.
Find elsewhere
๐ŸŒ
Devloprr
devloprr.com โ€บ other โ€บ how-to-find-python-path
How To Find Python Path - devloprr.com
import os my_path=os.environ.get("PYTHONPATH") print(my_path) #C:\Users\LENOVO\Desktop\pythonproject\findingpath
๐ŸŒ
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
๐ŸŒ
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?

๐ŸŒ
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 colon (:) separates multiple paths on Linux. Check if PYTHONPATH was set correctly ? echo $PYTHONPATH ยท This displays the current PYTHONPATH value, showing all directories Python will search for modules.
๐ŸŒ
CodeRivers
coderivers.org โ€บ blog โ€บ how-to-find-python-path
Finding the Python Path: A Comprehensive Guide - CodeRivers
February 22, 2026 - This code will print out all the directories that are currently in the Python path. The sys.path list is initialized from several sources, including the directory where the script is run, the standard library directories, and any directories specified by the PYTHONPATH environment variable.
๐ŸŒ
Simons-rock
hope.simons-rock.edu โ€บ ~pshields โ€บ cs โ€บ python โ€บ pythonpath.html
PYTHONPATH
Go to the Control Panel, open System, Choose Advanced, and click on the Environment Variables button. Check to see if there is already a variable called PYTHONPATH defined.
๐ŸŒ
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 ...
๐ŸŒ
sqlpey
sqlpey.com โ€บ python โ€บ solved-how-to-find-your-pythonpath-using-python
Solved: How to Find Your PYTHONPATH Using Python - sqlpey
December 5, 2024 - A: You can check if PYTHONPATH is defined by trying to access os.environ['PYTHONPATH'] in your Python script.
๐ŸŒ
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 - This output usually includes the current script directory, site-packages locations, standard library directories, and any paths injected from PYTHONPATH.
๐ŸŒ
CodeWithHarry
codewithharry.com โ€บ blogpost โ€บ how-to-find-python-installation-path
How to find the Python Installation Path on Windows? | Blog | CodeWithHarry
Discover how to locate the Python installation path on your Windows system using two effective methods: the traditional Command Prompt and the modern Terminal. Whether you're troubleshooting or setting up environment variables, this guide provides clear, step-by-step instructions with visuals ...
๐ŸŒ
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.