I'm having some strange issues getting dot2tex
to work as a module. I've tried both with pip install dot2tex
and with a fresh clone of this repository (75e6348), as well as with versions 1.5.7, 2.0.1, and 2.1.0 of pyparsing
. None of these combinations seem to work when calling dot2tex from as a module, e.g.,
I've also tried various combinations or arguments and all result in the same error. Everything seems fine when calling dot2tex
in stand-alone mode. Furthermore, dot2tex
2.9.0dev, which I got from here, also works fine (but only with pyparsing 1.5.7).
EDIT: I'm not sure what happened exactly, but somehow with all the installs and uninstalls I did, I now cannot make any version of dot2tex
work as a module or in stand-alone mode, even with the simplest possible graphs. I'll try later in a virtual environment and see if I can replicate what I was seeing earlier. Something strange is going on and I don't have the bandwidth to track it down fully at the moment. In any case, I'm still seeing the errors below, but with all versions now.
With a fresh install of dot2tex from Pypi and with any version of pyparsing, I get exactly the same error as reported here. I also get that error with a fresh clone of this repo with pyparsing 1.5.7. With a fresh clone of this repo and pyparsing >= 2.0, I get a different error, but the new error seems to be a red herring. The actual failure is in exactly the same place, it's just that the exception is being caught somewhere up the chain and this is leading to a missing file later in the execution.
I debugged it a bit and the real issue arises in a call to
parseImpl( self, instring, loc, doActions=True )
This fails with any input as far as I can tell, but in this case, instring
is something very simple:
str: graph G {
rankdir=LR;
layout=dot;
splines=true;
fontsize=44;
0 [shape=rect, label=x_3];
}
Ostensibly, the problem is that self.exprs
is
And: {['strict'] {'graph' | 'digraph'} [ID] Suppress:("{") Group:([None]) Suppress:("}")}
and it is the None
you see there that eventually causes the problem, but I couldn't manage to understand exactly what that object is or why None
appears there. This eventually results in the exception
File "c:\cygwin64\home\ted\coin\gimpy\src\gimpy\graph.py", line 1692, in display
tex = dot2tex.dot2tex(self.to_string(), autosize=True, texmode = 'math', template = DOT2TEX_TEMPLATE)
File "c:\python27\lib\site-packages\dot2tex-2.9.0-py2.7.egg\dot2tex\__init__.py", line 61, in dot2tex
return d2t.convert_graph(dotsource, **kwargs)
File "c:\python27\lib\site-packages\dot2tex-2.9.0-py2.7.egg\dot2tex\dot2tex.py", line 3103, in convert_graph
tex = main(True, dotsource, options)
File "c:\python27\lib\site-packages\dot2tex-2.9.0-py2.7.egg\dot2tex\dot2tex.py", line 3052, in main
s = conv.convert(dotdata)
File "c:\python27\lib\site-packages\dot2tex-2.9.0-py2.7.egg\dot2tex\dot2tex.py", line 760, in convert
main_graph = parse_dot_data(dotdata)
File "c:\python27\lib\site-packages\dot2tex-2.9.0-py2.7.egg\dot2tex\dot2tex.py", line 232, in parse_dot_data
graph = parser.parse_dot_data(dotdata)
File "c:\python27\lib\site-packages\dot2tex-2.9.0-py2.7.egg\dot2tex\dotparsing.py", line 594, in parse_dot_data
tokens = self.dotparser.parseString(ndata)
File "C:\Python27\lib\site-packages\pyparsing.py", line 996, in parseString
loc, tokens = self._parse( instring, 0 )
File "C:\Python27\lib\site-packages\pyparsing.py", line 871, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "C:\Python27\lib\site-packages\pyparsing.py", line 2342, in parseImpl
loc, exprtokens = e._parse( instring, loc, doActions )
File "C:\Python27\lib\site-packages\pyparsing.py", line 871, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "C:\Python27\lib\site-packages\pyparsing.py", line 2596, in parseImpl
return self.expr._parse( instring, loc, doActions, callPreParse=False )
File "C:\Python27\lib\site-packages\pyparsing.py", line 871, in _parseNoCache
loc,tokens = self.parseImpl( instring, preloc, doActions )
File "C:\Python27\lib\site-packages\pyparsing.py", line 2792, in parseImpl
loc, tokens = self.expr._parse( instring, loc, doActions, callPreParse=False )
AttributeError: 'NoneType' object has no attribute '_parse'
Hope this helps find the problem. I'm happy to help with making it reproducible for you. I can even tell how to install the package I'm using that calls dot2tex and send you a very short script that exhibits the error if that is needed.
I can use 2.9.0dev for now, but would like to be on the official version if possible. Thanks for the nice piece of software by the way!