我在Windows 7机器上使用Python 2.7.2,每次我想要访问Python时,我一直在命令提示符中设置PATH
变量。今天,我注意到如果我将目录附加到PATH
变量背面的前面,行为会发生变化。
在打开命令提示符时,它既不识别python
也不识别python.exe
:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\z1083743>python
The system cannot find the path specified.
C:\Users\z1083743>python.exe
'python.exe' is not recognized as an internal or external command,
operable program or batch file.
当我将python二进制目录添加到路径的后面时,它会识别一个而不是另一个:
C:\Users\z1083743>set PATH=%PATH%;C:\FUEL\std-1.4.10.1\Windows-x64-vs10.0\python-2.7.2\bin
C:\Users\z1083743>python
The system cannot find the path specified.
C:\Users\z1083743>python.exe
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z
如果我在路径的前面添加Python二进制目录,它会同时识别:
C:\Users\z1083743>set PATH=C:\FUEL\std-1.4.10.1\Windows-x64-vs10.0\python-2.7.2\bin;%PATH%
C:\Users\z1083743>python
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z
C:\Users\z1083743>python.exe
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z
我已经阅读了adding-python-path-on-windows-7问题的所有答案,但所有这些答案都旨在让它正常运行。据我所知,他们都没有描述我所看到的行为。
这里发生了什么?为什么在一个案例中需要.exe
扩展名而不在另一个案例中呢?