Python is on my machine, I just don’t know where, if I type python in terminal it will open Python 2.6.4, this isn’t in it’s default directory, there surely is a way of finding it’s install location from here?

sys has some useful stuff:

$ python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
>>> sys.exec_prefix
>>> print '\n'.join(sys.path)


In unix (mac os X included) terminal you can do

which python

and it will tell you.

Platform independent solution in one line is

Python 2:

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

Python 3:

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

For Windows CMD run: where python

For Windows PowerShell run: Get-Command python

Have a look at sys.path:

>>> import sys
>>> print(sys.path)

You should be able to type “which python” and it will print out a path to python.

or you can type:

>>> import re
>>> re.__file__

and it will print a path to the re module and you’ll see where python is that way.

To find all the installations of Python on Windows run this at the command prompt:

dir /s

Make sure you are in the root drive. You will see something like this.

If you are using wiindows OS (I am using windows 10 ) just type

where python   

in command prompt ( cmd )

It will show you the directory where you have installed .

For Windows Users:

If the python command is not in your $PATH environment var.

Open PowerShell and run these commands to find the folder

cd \
ls *ython* -Recurse -Directory

That should tell you where python is installed

  1. First search for PYTHON IDLE from search bar
  2. Open the IDLE and use below commands.

    import sys

  3. It will give you the path where the python.exe is installed. For eg:

  4. Add the same path to system environment variable.

On windows search python,then right click and click on “Open file location”.That’s how I did