Navigate to the directory C:\Users\Pattis\AppData\Local\Programs\Python\Python39 (or to whatever directory Python was installed: see the pop-up window for Installing step 1). Double-click the icon/file python.exe. The following pop-up window will appear.
In your Python interpreter, type the following commands:
>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)
'C:\\Python25'
Also, you can club all these and use a single line command. Open cmd and enter following command
python -c "import os, sys; print(os.path.dirname(sys.executable))"
If you have Python in your environment variable then you can use the following command in cmd or powershell:
where.exe python
or for Unix enviroment
which python
command line image :
It would be either of
If you need to know the installed path under Windows without starting the python interpreter, have a look in the Windows registry.
Each installed Python version will have a registry key in either:
HKLM\SOFTWARE\Python\PythonCore\versionnumber\InstallPath
HKCU\SOFTWARE\Python\PythonCore\versionnumber\InstallPath
In 64-bit Windows, it will be under the Wow6432Node
key:
HKLM\SOFTWARE\Wow6432Node\Python\PythonCore\versionnumber\InstallPath
Simple way is
where python
in cmdOn my windows installation, I get these results:
>>> import sys
>>> sys.executable
'C:\\Python26\\python.exe'
>>> sys.platform
'win32'
>>>
(You can also look in sys.path
for reasonable locations.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With