Closure Linter Windows Python 3.6 'SyntaxError: ugyldig syntaks'

Indlæg af Hanne Mølgaard Plasc

Problem



Jeg kan ikke køre Google Closure Linter på Windows 10 med Python 3.6. Jeg får følgende fejl med gjslint


PS C:Windowssystem32> gjslint
Traceback (most recent call last):
  File "C:Program FilesPython36Scriptsgjslint-script.py", line 11, in <module>
    load\_entry\_point('closure-linter==2.3.19', 'console\_scripts', 'gjslint')()
  File "c:program filespython36libsite-packagespkg\_resources\_\_init\_\_.py", line 565, in load\_entry\_point
    return get\_distribution(dist).load\_entry\_point(group, name)
  File "c:program filespython36libsite-packagespkg\_resources\_\_init\_\_.py", line 2631, in load\_entry\_point
    return ep.load()
  File "c:program filespython36libsite-packagespkg\_resources\_\_init\_\_.py", line 2291, in load
    return self.resolve()
  File "c:program filespython36libsite-packagespkg\_resources\_\_init\_\_.py", line 2297, in resolve
    module = \_\_import\_\_(self.module\_name, fromlist=['\_\_name\_\_'], level=0)
  File "c:program filespython36libsite-packagesclosure\_lintergjslint.py", line 176
    print '\%s: \%d' \% (path, len(path\_errors))
                 ^
SyntaxError: invalid syntax

Bedste reference


Du skal erstatte den til


print ('\%s: \%d' \% (path, len(path\_errors)))


I Python 2 er print en erklæring, men i Python 3 er print () en funktion
Jeg anbefaler også brug formatering som print ('{0}: {1}'.format (path, len(path\_errors)))