Reputation: 3372
I am using pygraphviz
1.6 to generate the a plot using Python 3.6. Unfortunately, I can't update Python.
While generating the graph, the command graph.layout("dot")
generates the error:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2882, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-4-d73a7e09eb44>", line 6, in <module>
graph.layout("dot")
File "/usr/local/lib/python3.6/dist-packages/pygraphviz/agraph.py", line 1422, in layout
data = self._run_prog(prog, " ".join([args, "-T", fmt]))
File "/usr/local/lib/python3.6/dist-packages/pygraphviz/agraph.py", line 1387, in _run_prog
raise OSError(b"".join(errors).decode(self.encoding))
OSError: libpath/shortest.c:324: triangulation failed
libpath/shortest.c:200: destination point not in any triangle
Error: in routesplines, Pshortestpath failed
In order to reproduce the issue, you must download the file graph_data.txt from https://drive.google.com/file/d/12YjB752SfCrzHmycRDeYAH2PHL6gMiIJ/view?usp=sharing , and run the following code:
import pygraphviz as pgv
with open("graph_data.txt", "wb") as fp:
graph_data = fp.read()
graph = pgv.AGraph()
graph.from_string(graph_data)
graph.layout("dot")
graph.draw(settings.PIPELINE_GRAPH_PATH, format="pdf")
Upvotes: 0
Views: 596
Reputation: 3372
Following @sroush I uninstalled graphviz and reinstalled it building from scratch. The following is the code to do that:
apt purge graphviz && \
pip uninstall graphviz && \
apt install -y libgts-dev && \
pkg-config --libs gts && \
pkg-config --cflags gts && \
wget https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/5.0.0/graphviz-5.0.0.tar.gz && \
tar -xvf graphviz-5.0.0.tar.gz && \
cd graphviz-5.0.0/ && \
./configure --with-gts && \
make && \
make install
Note that you may need to run some of the above commands with sudo
as done here: https://github.com/ellson/MOTHBALLED-graphviz/issues/1237#issue-226453389
Upvotes: 0
Reputation: 6763
Curious!
There are several Graphviz issues open with similar descriptions. https://gitlab.com/graphviz/graphviz/-/issues/1323 seems useful. But no current solution.
However, I can't get your example to fail on my Linux system (Mint)! Even when using a years-old Graphviz version.
So, old Python does not seem to be the problem.
OS-related, maybe?
Triangulation library (https://gitlab.com/graphviz/graphviz/-/issues/1269), maybe.
Resulting file is 6M (png), too big to upload.
Upvotes: 1