In this short guide, you’ll see two methods to find where Python is installed on Windows:
- Using the sys library
- Manually
Find Where Python is Installed on Windows using the Sys Library
You can use the sys library in order to find where Python is installed:
import sys print(sys.exec_prefix)
Here is an example of a path structure that you may get:
C:\Users\Ron\AppData\Local\Programs\Python\Python311
Manually Locate Where Python is Installed
Alternatively, you can manually locate where Python is installed by following these steps:
- Type ‘Python’ in the Windows Search Bar
- Right-click on the Python App, and then select “Open file location“
- Right-click again on the Python shortcut, and then select “Open File Location“
You’ll now get the location/path where your Python is installed on Windows:
C:\Users\Ron\AppData\Local\Programs\Python\Python311
Notice that the path under this method matches to the path found under the first method.
Once you retrieved the above path, you’ll be able to upgrade pip for example.