[Tutor] Runs in IDLE with F5, but not in Windows Command Prompt

boB Stepp robertvstepp at gmail.com
Thu Apr 25 14:40:21 CEST 2013


Hi Steve,

>
>> E:\Programs\Python\IYOCGwPy\Ch4>guess.py
>
> Here you are telling Windows to look up the file association for .py files.
> It locates some program, and runs it with guess.py as the argument. Looking
> at the result:
>
>> Hello! What is your name?
>> boB
>> Traceback (most recent call last):
>>    File "E:\Programs\Python\IYOCGwPy\Ch4\guess.py", line 13, in <module>
>>      playerName = input()
>>    File "<string>", line 1, in <module>
>> NameError: name 'boB' is not defined
>
> this is obviously Python 2.x rather than 3.3.1. You can check that by
> putting these two lines at the very beginning of the program:

One thing that no one has addressed so far is why when I put quotes
around my input, as in 'boB', the program does run in the command
prompt.

>
> import sys
> print(sys.version)
>
>
> My bet is that if you run it like this:
>
>
> python guess.py
>
>
> it will print "3.3.1" and the program will work, but when you run it like
> this:
>
>
> guess.py
>
>
> it will print 2.something and then fail.

I am at work now and cannot do these checks. I suspect you are correct
in every particular!

>> E:\Programs\Python\IYOCGwPy\Ch4>
>>
>> This has me totally puzzled. I thought it might have something to do
>> with the fact that I also have Python 2.7 installed, so I removed it
>> from the path variable and also did the check for version that you see
>> above.
>
>
> There's your bunny. Just because you remove it from the search path doesn't
> mean that Windows won't use it.
>
> You might like to remove Python 2.7 altogether, or at least unassociate it
> from the .py file extension.
>
I am beginning to see that instead of "winging it" with installing
BOTH Python 2.7 and Python 3.3, that I should have done some research
first on how to have both Pythons coexist amicably, leaving Python 3.3
as my default for .py files. The reason that I want 2.7 is that at
work after our recent upgrades we have Python 2.4.6 installed on some
machines and 2.4.4 on others. My intention was to try out some Python
2.x stuff at home prior to start using it at work as a replacement for
the scripting I have been to date doing in Perl.

Thanks, Steve (and everyone else!)!
boB


More information about the Tutor mailing list