“蟒蛇"不被识别为命令 [英] "python" not recognized as a command

查看:42
本文介绍了“蟒蛇"不被识别为命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将 Python 2.7.2 下载并安装到我的笔记本电脑上,我正在尝试运行一些示例程序.我的笔记本电脑运行的是 Windows XP.

I just downloaded and installed Python 2.7.2 to my laptop and I am trying to run some sample programs. My laptop is running Windows XP.

当我打开一个 cmd 窗口并输入 python 时,我得到:

When I open a cmd window and type python I get:

'python' 不是内部或外部命令,也不是可运行的程序或批处理文件.

'python' is not recognized as an internal or external command, operable program or batch file.

我不是 Windows 人(主要是大型机).但是我猜测我需要执行一些命令才能将 python 定义为命令.谁能告诉我那个命令是什么?

I am not a Windows person (mostly mainframes). However I am guessing that there is some command that I need to execute to define python as a command. Can anyone tell me what that command is?

安装程序将 Python 放置在 C:\Python27\.

The installer placed Python at C:\Python27\.

推荐答案

您需要将 python 可执行文件路径添加到 Window 的 PATH 变量中.

You need to add the python executable path to your Window's PATH variable.

  1. 在桌面上,右键单击我的电脑",然后单击属性".
  2. 在系统属性"窗口中,单击高级"选项卡.
  3. 在高级部分,点击环境变量按钮.
  4. 突出显示系统变量"部分中的路径"变量,然后单击编辑"按钮.
  5. 添加 Python 可执行文件的路径 (c:\Python27\).每个不同的目录用一个分号.(注意:不要在 PATH 中的元素之间放置空格.您添加到 PATH 应该阅读 ;c:\Python27 而不是 ; C\Python27)
  6. 应用更改.您可能需要重新启动系统,但只需重新启动 cmd.exe 就足够了.
  7. 启动 cmd 并重试.它应该可以工作.
  1. From the desktop, right-click My Computer and click Properties.
  2. In the System Properties window, click on the Advanced tab.
  3. In the Advanced section, click the Environment Variables button.
  4. Highlight the Path variable in the Systems Variable section and click the Edit button.
  5. Add the path of your python executable(c:\Python27\). Each different directory is separated with a semicolon. (Note: do not put spaces between elements in the PATH. Your addition to the PATH should read ;c:\Python27 NOT ; C\Python27)
  6. Apply the changes. You might need to restart your system, though simply restarting cmd.exe should be sufficient.
  7. Launch cmd and try again. It should work.

这篇关于“蟒蛇"不被识别为命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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