pip install pydot raises a SyntaxError

2020-04-12 10:12发布

问题:

I'm running pip from the command line, trying to install pydot because Django's django-extensions needs it to generate UML class diagrams

When I run the command pip install pydot, it gives me this error:

Collecting pydot
  Using cached pydot-1.0.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "C:\Users\[me]\AppData\Local\Temp\pip-build-uscu27_d\pydot\setup.py
", line 5
        except ImportError, excp:
                          ^
    SyntaxError: invalid syntax

The same error happens with easy_install pydot.

Looks like the correct syntax would be except ImportError as excp, but I don't know what to do about this. The version of Python I'm using is 3.4.3. Do I have to downgrade my version of Python to get this to work, or is there some other way?

回答1:

This error is due to the old exception syntax of python2.

Since pydot seems to be a very old library and no longer maintained, I'd suggest forking it and correct this error yourself.