Reputation: 375
Using python 2.7.11 on Windows 10 64-bit Home Premium upgraded in place from Windows 7
In a standard console, the following code is saved as hello.py and prints:
Hello World
When invoked with
python hello.py
#! python
print 'Hello World'
It produces no console output at all when invoked with
hello.py
or hello
The program runs in all three cases.
I can demonstrate this by adding
with open('world.txt', 'w') as fh:
fh.write('dolly\n')
Each of the three methods of invoking the program all successfully write world.txt with the correct information.
python.exe is in my path
.py is in the pathext variable
.py is associated with python.exe, and the correct command line is in the "shell open" registry entry.
all of the above is in accordance with
https://docs.python.org/2/faq/windows.html
I had no trouble running python scripts from the command line without the extension in Windows 7
Thanks,
Upvotes: 3
Views: 3094
Reputation: 375
On a whim, I navigated to the registry key specified in my previous comment.
The instruction here: https://support.microsoft.com/en-us/kb/321788
Say to add a REG_DWORD value "InheritConsoleHandles" to the key
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
and set its value to 1
I set its value to 0 and opened a new command prompt. Subsequently, running python scripts without their extensions "just works"
I love whims
Upvotes: 1