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

eryksun eryksun at gmail.com
Thu Apr 25 06:36:40 CEST 2013


On Thu, Apr 25, 2013 at 12:11 AM, boB Stepp <robertvstepp at gmail.com> wrote:
> NameError: name 'boB' is not defined
>
> 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.

In 2.x the input() function evaluates the input string; typically
you'd use raw_input() instead.

.py files need to be associated with %windir%\py.exe. Additionally you
need a py.ini in %localappdata% if you want to set Python 3 as the
default.

    C:\>assoc .py
    .py=Python.File

    C:\>ftype Python.File
    Python.File="C:\Windows\py.exe" "%1" %*

    C:\>type "%localappdata%\py.ini"
    [defaults]
    python=3

    C:\>py -V
    Python 3.3.1

    C:\>py -2.7 -V
    Python 2.7.3

If .py files are set up to use py,.exe, then you can use a shebang on
the first line to set the interpreter a script should use:

    #!/usr/bin/env python3

or for the highest 2.x installed:

    #!/usr/bin/env python2


More information about the Tutor mailing list