cmd 需要“.exe”来运行程序

cmd 需要“.exe”来运行程序

Windows 7,cmd:

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

C:\>python.exe
(works)

C:\>bash
'bash' is not recognized as an internal or external command,
operable program or batch file.
C:\>bash.exe
(works)

ETC...

有没有办法让我在输入“python”时运行 python.exe?

答案1

确保.exe在你的%PATHEXT%

C:\>set pathext
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.py;.pl

当您运行时python,Windows 会尝试该环境变量中列出的所有扩展。

C:\>set pathext=.exe;%pathext%

相关内容