Python 路径目录

Python Path Directory

我目前在学校使用 Windows XP 计算机。我的问题是如何在命令行中找到 运行 Python 的确切路径变量。我尝试了多个目录,但它们都一直显示“'python' 未被识别为内部或外部命令、可运行程序或批处理文件。”有没有简单的方法可以找到这个?

如果安装没问题。您可以使用 python,打开命令提示符 window 并导航到您的 Python 安装目录(默认为 C:\Python27)。从此位置键入 python 以启动 Python 解释器。

Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

C:\Users\Username> cd C:\Python27

C:\Python27> python
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

另一种安装方法 tutorial

您可以从任何位置 运行 Python,而不必经常引用完整的安装路径名。

这可以通过将 Python 安装路径添加到 Windows' PATH ENVIRONMENT VARIABLE
来完成 *在Windows 7 和Windows 8 中,只需搜索“环境变量”即可将选项呈现给Edit the system environment variables。这将打开 System Properties / Advanced 选项卡
*在 Windows XP 中,右键单击 My Computer->Properties 打开 System Properties 并单击 Advanced 选项卡。

  1. System Properties / Advanced 选项卡上,单击 Environment Variables 打开 User VariablesSystem Variables

  2. 创建一个新的 System Variable 命名变量名称:PYTHON_HOME 和变量值:c:\Python27(或任何您的安装路径)

  3. 找到名为Path的系统变量并点击Edit

  4. 将以下文本添加到变量值的末尾:;%PYTHON_HOME%\;%PYTHON_HOME%\Scripts\

  5. 通过打开新的命令提示符 window(重要!)并从任何位置键入 python 来验证环境变量更新是否成功。