0

I was about to test the ftpmirror builtin script (python322, winXP 32bits) from the cmd windows default shell and get this :

File "C:\Program Files\python322\Tools\Scripts\ftpmirror.py", line 161
print('Skip pattern', repr(pat), end=' ')
                                    ^
SyntaxError: invalid syntax

I tested the print() line directly in the python shell, trough cmd, and with idle (and in blender also) : this work obsiously.

I reproduce the error with a coucou.py file like this :

#! /usr/bin/env python3
pat = 'toto'
print("Skip pattern", repr(pat), end=" ")

when directly called from a cmd prompt :

C:\Program Files\python322\Tools\Scripts>coucou.py

same error than with ftpmirror but :

C:\Program Files\python322\Tools\Scripts>python coucou.py

is ok

and my environment is ok I can execute py scripts directly from the windows ui by double-clicking a .py file, and I got working scripts working fine when called from .bat

I don't get it, it looks specific to the print() end argument, what did I not read yet about the way to execute python3 from the windows cmd shell ?

thanks,

Jerome

1
  • 5
    Do you also have Python 2.x installed on your computer? Commented Dec 19, 2012 at 18:15

1 Answer 1

4

Try checking if you are running the same python interpreter when you double click or you run python from the command-line.

Save this in a .py file with this content and try running it with both methods:

import sys
print sys.version_info

I bet you are using different interpreters in each case.

Sign up to request clarification or add additional context in comments.

2 Comments

omg... many thanks... sorry... PYTHONPATH=C:\Progra~1\python322\;C:\Progra~1\python266 my system is a mess :)
'open with...' on the py file REFUSES to let me choose python322 because of a dummy case (266/python.exe and 322/python.exe share the same name.) so I edited directly the registry and replaced any reference to the 266 path in HKEY_CLASSES_ROOT\Python.File by the 322 path. it looks ok now. if you want to be able to select between different python versions using 'open with' when right-clicking on a py file, one can duplicate each python.exe and rename to python266.exe, python272.exe 322 etc and then choose them when configuring 'open with'(alternatively I bet one can also read the python doc?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.