Find where python is installed (if it isn't default dir)

后端 未结 11 1413
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 06:09

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 f

相关标签:
11条回答
  • 2020-12-04 06:41

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

    dir site.py /s
    

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

    0 讨论(0)
  • 2020-12-04 06:46

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

    or you can type:

    python
    >>> import re
    >>> re.__file__
    

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

    0 讨论(0)
  • 2020-12-04 06:47

    On windows search python,then right click and click on "Open file location".That's how I did

    0 讨论(0)
  • 2020-12-04 06:50

    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 .

    0 讨论(0)
  • 2020-12-04 06:55

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

    which python
    

    and it will tell you.

    0 讨论(0)
  • 2020-12-04 06:56

    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)"
    
    0 讨论(0)
提交回复
热议问题