Closed
Description
On Windows 10 & Python 2.7
After MANY installation errors with pygraphviz I've come to this one which it seems I'm not able to solve by myself:
File "C:\Python27\lib\site-packages\transitions\extensions\diagrams.py", line 332, in __init__
model.get_graph()
File "C:\Python27\lib\site-packages\transitions\extensions\diagrams.py", line 345, in _get_graph
else Graph(self).get_graph(title)
File "C:\Python27\lib\site-packages\transitions\extensions\diagrams.py", line 172, in get_graph
self._add_edges(self.machine.events.copy(), fsm_graph)
File "C:\Python27\lib\site-packages\transitions\extensions\diagrams.py", line 130, in _add_edges
container.add_edge(src, dst, **edge_attr)
File "C:\Python27\lib\site-packages\pygraphviz\agraph.py", line 478, in add_edge
eh = gv.agedge(self.handle, uh, vh, str(key), _Action.find)
KeyError: 'agedge: no key'
it seems it is caused by some transitions configurations like this:
['any_trigger', 'same_state', 'same_state'],
or
['anything', '*', 'any_state'],
Activity
aleneum commentedon Sep 29, 2017
Hello @fedpet,
this is a reoccurring problem of
pygraphviz
under Windows. It has been reported before (#133), asked before at SO and also reported to pygraphviz (pygraphviz/pygraphviz#88) and networkx (networkx/networkx#2012). Since the issue has been closed in the pygraphviz tracker, I assume that it might be fixed inpygraphviz
version 1.4rc1. In a pull request (#217) a user mentions a workaround for that issue.Long story short: afaik we cannot do much about it since it seems to be related to
pygraphviz
and Windows, nottransitions
.fpettinari commentedon Sep 29, 2017
the error only happens when I try to draw reflexive transitions or ones which have '*' as the source.
btw if the problem is pygraphviz then what version are you officially using?
I see the repo examples are working..
edit.
I cloned and installed pygraphviz and it should be version 1.5.dev
same error
edit.
tried with version 1.4rc1.. same error
aleneum commentedon Sep 30, 2017
It shouldn't matter (we have used a couple of versions) as the issue is exclusive to Windows. Our test servers run Ubuntu 14.04 and I work with OSX Sierra (both use pygraphviz 1.3.1 currently). I have also used
transitions
on Ubuntu 16.04. Never had this issue. This code:produces this result:
I assume this would not work in your environment.
Bummer, it seems like they closed the issue without actually fixing it then. Thanks for giving it a try.
aleneum commentedon Sep 30, 2017
I am trying to set up a Windows CI test job but installing pygraphviz does not play very nice.
@fedpet: How did you install pygraphviz? Unfortunately, using pip after installing Graphviz finishes but I end up with DLL import errors (event though PATH is set correctly). The only way I got it to work was by using the unofficial binary builds that are suggested occasionally but this does not look like a way suitable for an automatic build process.
aleneum commentedon Oct 1, 2017
Nevermind, PATH has not been set correctly. Our tests fail on Windows as you can see here. I also added some try/catch phrases in the
dev-appveyor
branch to get some error messages. As mentioned in the above referenced issues/posts this error occurs only when source and destination of an edge are the same. I tried to omit extra attributes like labels but this does not work as well.I do not see what we could do differently given the fact that we have no platform specific code and tests do succeed on Linux and OSX. If you have any suggestions about how to approach this issue I am all ears.
fpettinari commentedon Oct 1, 2017
hi aleneum, thank you for your support.
Exactly
This. I'm not using unofficial binaries. Glad to see you found the problem :)
Your answer suggests me the problem may be on pygraphviz or graphviz side.
A minimal code example demonstrating this bug would be needed to be able to open a proper bug report on pygraphviz/pygraphviz or graphviz-issue-tracker
aleneum commentedon Oct 2, 2017
Hi @fedpet,
I added a minimal test to
dev-appveyor
:Status *nix: works
Status Windows: fails with Graphviz 2.38.0.1, pygraphviz 1.3.1
aleneum commentedon Mar 20, 2020
For everyone having similar issues in 2020:
I tried the minimal example (ref) and the graph (ref) with Graphviz 2.41 64-bit from here (link is also mentioned on the Graphviz page here) and pygraphviz 1.6.dev0 with the patch mentioned here (see this discussion).
Both seem to work. If you experience issues with
pygraphviz
you can usetransitions
with thegraphviz
package as mentioned in the ReadMe: