pydot and graphviz error: Couldn't import dot_parser, loading of dot files will not be possible pydot and graphviz error: Couldn't import dot_parser, loading of dot files will not be possible python python

pydot and graphviz error: Couldn't import dot_parser, loading of dot files will not be possible


Answer for pydot >= 1.1:

The incompatibility of (upstream) pydot has been fixed by 6dff94b3f1, and thus pydot >= 1.1 will be compatible with pyparsing >= 1.5.7.


Answer applicable to pydot <= 1.0.28:

For anyone else who comes across this, it is due to the changes in pyparsing from 1.x to the 2.x release.To install pydot using pip, first install the older version of pyparsing:

pip install pyparsing==1.5.7pip install pydot==1.0.28

If you did not install pyparsing using pip, but instead used setup.py, then have a look at this solution to uninstall the package. Thanks @qtips.


There is a new package in the pip repo called pydot2 that functions correctly with pyparsing2. I couldn't downgrade my packages because matplotlib depends on the newer pyparsing package.

Note: python2.7 from macports


pydot used a private module variable (_noncomma) from pyparsing. The below diff fixes it to use for pyparsing 2.0.1:

diff --git a/dot_parser.py b/dot_parser.pyindex dedd61a..138d152 100644--- a/dot_parser.py+++ b/dot_parser.py@@ -25,8 +25,9 @@ from pyparsing import __version__ as pyparsing_version from pyparsing import ( nestedExpr, Literal, CaselessLiteral, Word, Upcase, OneOrMore, ZeroOrMore,     Forward, NotAny, delimitedList, oneOf, Group, Optional, Combine, alphas, nums,     restOfLine, cStyleComment, nums, alphanums, printables, empty, quotedString,-    ParseException, ParseResults, CharsNotIn, _noncomma, dblQuotedString, QuotedString, ParserElement )+    ParseException, ParseResults, CharsNotIn, dblQuotedString, QuotedString, ParserElement )+_noncomma = "".join( [ c for c in printables if c != "," ] ) class P_AttrList: