Python supported various inbuilt and open-source modules. To use these modules and their functions, we need to import them at the start of the program. The Python interpreter will not import these modules if we don’t add a Python path to the window path. It is necessary to find the Python paths and map them to Windows otherwise; these modules can not be accessible in the Python program.
To find the Python path or where Python is installed on windows, various functions are used, such as using the “where python” command in the cmd terminal, using system properties, etc.
This post provides multiple methods to find installed Python paths on windows:
- Method 1: Using CMD Terminal
- Method 2: Using the sys Library
- Method 3: Using Windows Startup Menu
- Method 4: Using System Properties
Method 1: Using CMD Terminal
The path of the installed Python can be found using the following command in cmd terminal:
Using where python
The easiest way to find where Python is installed on windows is using “where python” command in cmd terminal:
The above snippet shows the path of the installed Python.
Using py –list-paths
The “py –list-paths” command can be used as an alternative to getting the installation path of installed Python:
The path of the installed Python has been displayed successfully.
Method 2: Using the sys Library
The “sys” library interacts with the Python interpreter and runtime environment through various functions. The “sys.exec_prefix” is used to find the path of the installed Python:
import sys print(sys.exec_prefix)
The “sys” module is imported. The “sys.exec_prefix” is passed as an argument to print() function to show the installed Python path.
The installed Python path has been displayed.
Method 3: Using Windows Startup Menu
The third simple method to find where Python is installed on windows is using the startup menu search. To open a Python-installed path, you need to type “python.exe” in the search bar and click on the “open the file location” option.
The Python-installed path has been opened, and the “exe” file shows the installed Python.
Method 4: Using System Properties
The manual way of opening the installed Python path is done using the system properties of the system. But this method is only applicable if your Python path is added to the windows path at the time of installation or later. To add Python to the windows path, check this specific guide.
Now after adding the Python path to the window path, you can follow the below steps to get the Python installation path:
Step 1: Open the Run dialog box and type “sysdm.cpl” in the run dialog box:
Step 2: Select environment variables from the advanced option.
Step 3: Select the Python path and click on the “Edit” button.
Step 4: The path of all installed Python is located in the environment variable setting.
To find where Python is installed on windows, various methods such as CMD terminal, sys library, startup menu search, and system properties are used in Python. The “where python” and “py –list-paths” commands are used to get the installed Python path. Similarly, opening the file location of the “python.exe” file from the start menu search will also open the installed Python path. This post presented various methods to find where Python is installed on Windows.