Where is the Python home directory?

I have Python 2.7 installed, I am looking at the tensorflow process and for windows it looks like it only works in python 3.5, I downloaded the python installer and it appears to be installed, but where?

Python 2.7 has a Python27 directory at C :, but I can't find 3.5 anywhere. I tried the installer again and it asked if I wanted to repair or uninstall.

EDIT: I'm really trying to find pip3, which I believe is in the python35 / scripts directory

+3


source to share


1 answer


Where is Python installed? or where is the Python HOME directory located?

An easy way to find where Python is installed:

import sys
print(sys.executable)

      

What are the outputs for me:

C:\Users\Vallentin\AppData\Local\Programs\Python\Python36-32\python.exe

      

You can also use sys.exec_prefix

which would be equivalent os.path.dirname(sys.executable)

.

If you then copy part of the directory and paste it into Windows Explorer. This will then take you to your Python home directory. Then you are correct that the pip will be located at.

C:\Users\Vallentin\AppData\Local\Programs\Python\Python36-32\Scripts\pip3.exe

      


On the command line, this can also be done in one line:



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

      

Alternatively, you can also:

  • which python

    (Unix)
  • where python

    (Windows)

Where is the Python module installed?

If you want to find where a Python module is located, for example, print(__file__)

you can do the same with modules:

import re
import flask

print(re.__file__)
print(flask.__file__)

      

What are the outputs for me:

C:\Users\Vallentin\AppData\Local\Programs\Python\Python36-32\lib\re.py
C:\Users\Vallentin\AppData\Local\Programs\Python\Python36-32\lib\site-packages\flask-0.12-py3.6.egg\flask\__init__.py

      

+6


source







All Articles