如何从Windows cmd运行Python

2024-04-25 14:49:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在Windows中运行一个python程序,调用如下:

python pacman.py

我对python程序有很多这样的调用。我想从windows命令行运行它。当我在Ubuntu中运行这个程序时,它运行得很好,但是当我在Windows中尝试它时,我得到以下错误:

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

如何从Windows cmd运行这些python程序?


Tags: or命令行py程序anisubuntuwindows
3条回答

这意味着没有声明Python路径。试试这个:

cd --> to pacman.py dir
C:\PythonVersion\python.exe pacman.py

您需要修改Windows%PATH%环境变量。在My Computer‣Properties‣Advanced‣环境变量下,您应该修改%PATH%变量以包含您的Python目录,即C:\ Python26。

见:http://docs.python.org/2/using/windows.html#excursus-setting-environment-variables

尝试使用这个,目录C:\ py*,它应该会给您一个这样的消息 “驱动器C中的卷:Windows版本--- 卷序列号 C目录: 还有一个Python的路径,它安装在你的计算机上“,如果你得到这个,你很好去。。。

相关问题 更多 >