如何在 Windows 上找到 Python 的安装位置? [英] How can I find where Python is installed on Windows?

查看:37
本文介绍了如何在 Windows 上找到 Python 的安装位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Windows 上找出我的 Python 安装路径.例如:

C:Python25

如何找到 Python 的安装位置?

解决方案

在您的 Python 解释器中,键入以下命令:

<预><代码>>>>导入操作系统>>>导入系统>>>os.path.dirname(sys.executable)'C:\Python25'

此外,您可以使用所有这些并使用单行命令.打开cmd,输入以下命令

python -c "import os, sys;打印(os.path.dirname(sys.executable))";

I want to find out my Python installation path on Windows. For example:

C:Python25

How can I find where Python is installed?

解决方案

In your Python interpreter, type the following commands:

>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)
'C:\Python25'

Also, you can club all these and use a single line command. Open cmd and enter following command

python -c "import os, sys; print(os.path.dirname(sys.executable))"

这篇关于如何在 Windows 上找到 Python 的安装位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆