1

Following the examples on https://networkx.github.io/documentation/stable/reference/drawing.html, I tried the following code:

import networkx as nx
G = nx.complete_graph(5)
A = nx.nx_agraph.to_agraph(G)
H = nx.nx_agraph.from_agraph(A)

I get a RuntimeError as follows:

H = nx.nx_agraph.from_agraph(A)
Traceback (most recent call last):

  File "/home/nom/anaconda3/envs/wcats/lib/python3.7/site-packages/pygraphviz/agraph.py", line 1750, in iteritems
    ah = gv.agnxtattr(self.handle, self.type, ah)

StopIteration: agnxtattr


The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  File "<ipython-input-10-19c378da806e>", line 1, in <module>
    H = nx.nx_agraph.from_agraph(A)

  File "/home/nom/anaconda3/envs/wcats/lib/python3.7/site-packages/networkx/drawing/nx_agraph.py", line 85, in from_agraph
    N.graph.update(A.graph_attr)

  File "/home/nom/anaconda3/envs/wcats/lib/python3.7/site-packages/pygraphviz/agraph.py", line 1740, in keys
    return list(self.__iter__())

  File "/home/nom/anaconda3/envs/wcats/lib/python3.7/site-packages/pygraphviz/agraph.py", line 1743, in __iter__
    for (k, v) in self.iteritems():

RuntimeError: generator raised StopIteration

This error is so basic that I suspect there's a problem with the package itself. Any suggestions on how I can try to troubleshoot this one?

  • What versions of `networkx` and `pygraphviz` are you running? – Joel Aug 26 '20 at 00:16
  • Based on this: https://stackoverflow.com/questions/51700960/runtimeerror-generator-raised-stopiteration-every-time-i-try-to-run-app, it looks to me like this is an incompatibility of your version of pygraphviz with Python 3.7. – Joel Aug 26 '20 at 11:24
  • 1
    I am running python 3.8 and I was running pygraphviz 1.3 which is what conda installed automatically. I saw that pygraphviz is on on v1.6 and I installed this version with pip. That fixed everything. Apparently this error became a known issue in PEP 479 and it broke older versions of pygraphviz and other software. See https://github.com/pygraphviz/pygraphviz/issues/168. – CheeseArchitect Aug 26 '20 at 16:17

0 Answers0