So I was using pydot in python 2.7 from Anaconda and noticed I keep getting errors when I attempt to use certain strings in Pydot.
The error I have isolated to:
import pydot
graph = pydot.Dot(graph_type='digraph', rankdir = 'LR')
S = 'Total Flow Count ' + ':' + str(3)
legend = pydot.Node('Legend', label=S, shape='rectangle')
graph.add_node(legend)
Whenever I run this I get the following output:
Traceback (most recent call last):
File "path\of\my\code\errorisolate.py", line 13, in <module>
graph.write_png('example5graph.png')
File "c:\Anaconda\lib\site-packages\pydot.py", line 1609, in <lambda>
lambda path, f=frmt, prog=self.prog : self.write(path, format=f, prog=prog))
File "c:\Anaconda\lib\site-packages\pydot.py", line 1703, in write
dot_fd.write(self.create(prog, format))
File "c:\Anaconda\lib\site-packages\pydot.py", line 1803, in create
status, stderr_output) )
InvocationException: Program terminated with status: 6. stderr follows: Error: c:\users\sidharth\appdata\local\temp\tmpxvwsls:3: syntax error near line 3
context: Legend [shape=rectangle, label=Total Flow Count >>> : <<< 3];
Analysis/Work So Far:
Somehow the combination of a colon character ':' followed by a number in str() format seems to raise an error. I tried to fix it by append the 'r' in front since I know that is a way to fix errors invlving the '\n' character. But even then no luck.
Changes:
I removed the r as it appears to be causing a little confusion. I had kept r':' hoping to emulate the solution to the problem of non compiling newlines '\n', since pydot requires them to be listed as r'\n' where r is explicitly not defined.
As per: