Python在我的机器上,我只是不知道在哪里,如果我在终端中输入Python,它会打开Python 2.6.4,这不是在它的默认目录中,肯定有一种方法可以从这里找到它的安装位置?


当前回答

平台独立的解决方案在一条线上

Python 2:

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

Python 3:

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

其他回答

要找到Windows上所有的Python安装,在命令提示符处运行:

dir site.py /s

确保您在根驱动器中。你会看到类似这样的东西。

在windows搜索python,然后右键单击“打开文件位置”。我就是这么做的

平台独立的解决方案在一条线上

Python 2:

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

Python 3:

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

首先从搜索栏中搜索PYTHON IDLE 打开IDLE并使用以下命令。 导入系统 打印(sys.path) 它会告诉你安装python.exe的路径。如: C:\Users\ \…\ python.exe 为系统环境变量添加相同路径。

对于Windows CMD,执行:where python . exe

Windows PowerShell: Get-Command python