how to get python installed path from command line

83,674

Solution 1

try opening up cmd and simply:

where python

By default, this searches your PATH for matches. More precisely:

Description: Displays the location of files that match the search pattern. By default, the search is done along the current directory and in the paths specified by the PATH environment variable.

Most windows python installers modify your PATH so this should find what doing python at the CLI will call.

Solution 2

Cross-platform solution using sys.executable

python -c "import sys; print(sys.executable)"

sys.executable

A string giving the absolute path of the executable binary for the Python interpreter, on systems where this makes sense.

Solution 3

You can check registry by: HKLM SOFTWARE\Python\PythonCore\${PYTHON_VERSION}\InstallPath

or HKCU

Share:
83,674

Related videos on Youtube

user2499879
Author by

user2499879

Updated on November 07, 2020

Comments

  • user2499879
    user2499879 over 3 years

    I am trying to get the installed path of python? Any idea how to get the python installed path from command line in windows. I don't want to set the environment variable?

    Thanks,

  • thefourtheye
    thefourtheye over 10 years
    where works with windows?
  • roippi
    roippi over 10 years
    @thefourtheye yes. in *nix it's which.
  • Prashant Singh
    Prashant Singh almost 7 years
    HKCU worked for me: PS C:\Windows\system32> Get-Item -Path Registry::HKEY_Current_User\Software\Python\PythonCore\3.6-3‌​2\InstallPath
  • Jero Dungog
    Jero Dungog over 5 years
    Great! direct to the point
  • heySushil
    heySushil over 3 years
    thank you where much I really tired looking for the alternative of which of Linx command and last I got where after 1 hour of search this is really what I say......
  • jshd
    jshd almost 3 years
    The nice thing about using "where" is that if you have more than 1 file with the same name in your path (which can lead to annoying issues) it will list all of them.