0

I am using Python 2.7.2 on a Windows 7 machine, and I have been setting the PATH variable in the command prompt each time that I want access to Python. Today, I noticed that the behavior changes if I append the directory to the front of the back of the PATH variable.

On opening a command prompt, it recognizes neither python or 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.

When I add the python binary directory onto the back of the path, it recognizes one but not the other:

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

If I add the Python binary directory on the front of the path, it recognizes both:

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

I've read through all of the answers to the adding-python-path-on-windows-7 question, but all of them are aimed at just getting it working. As far as I can tell, none of them would describe the behavior that I'm seeing.

What's happening here? Why does it need the .exe extension in one case and not the other?

Community
  • 1
  • 1
Cody Martin
  • 134
  • 2
  • 10
  • 2
    There's some other `python` in another `PATH` directory with an extension that's in `PATHEXT`, but not .exe. Check `where python`. – Eryk Sun Apr 10 '15 at 00:18
  • That was it! There was a `python.cmd` in one of the other directories that pointed to a (non-existent) `python.exe` path. – Cody Martin Apr 10 '15 at 00:49
  • Now for meta: why comment instead of answer? What do I do once someone has satisfactorily answered the question? – Cody Martin Apr 10 '15 at 00:50

0 Answers0