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


当前回答

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

which python

它会告诉你。

其他回答

看看sys.path:

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

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

Windows用户:

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

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

cd \
ls *ython* -Recurse -Directory

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

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

which python

它会告诉你。

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

Python 2:

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

Python 3:

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