When I run a very simple code with pydot
import pydot graph = pydot.Dot(graph_type='graph') for i in range(3): edge = pydot.Edge("king", "lord%d" % i) graph.add_edge(edge) vassal_num = 0 for i in range(3): for j in range(2): edge = pydot.Edge("lord%d" % i, "vassal%d" % vassal_num) graph.add_edge(edge) vassal_num += 1 graph.write_png('example1_graph.png')
It prints me the error message:
Couldn't import dot_parser, loading of dot files will not be possible.
I'm using python 2.7.3
Pydot is a Python library, also written in Python, that "serves as a graphical interface to Graphviz, an open source graph visualization software. GraphViz is written in DOT language, but Pydot provides the ability to parse and dump data, between Python and DOT."[
Type conda install pydot graphviz in cmd, and then add the executables location directory C:\Anaconda3\pkgs\graphviz-2.38-hfd603c8_2\Library\bin\graphviz to your system path variable. That works! It works!
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.7 pip 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With