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


当前回答

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

Windows PowerShell: Get-Command python

其他回答

看看sys.path:

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

Windows用户:

如果python命令不在您的$PATH环境中。

打开PowerShell并运行这些命令以找到该文件夹

cd \
ls *ython* -Recurse -Directory

这应该会告诉你python安装在哪里

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

Python 2:

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

Python 3:

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

运行以下命令

where python

在unix(包括mac os X)终端上可以这样做

which python

它会告诉你。