Pretty sure this is a question where I'm missing something simple/basic.
I recently upgraded pydrake
to 1.32. When exporting the Diagram
to SVG, it marks deprecated ports with the tombstone emoji, '\U0001faa6'
. Something in the pydot pipeline is choosing to use ascii instead of unicode, and it's crashing my script.
Here's the offending line:
pydot.graph_from_dot_data(diagram.GetGraphvizString())[0].create_svg("diagram.svg")
I'm getting this UnicodeEncodeError
:
'ascii' codec can't encode character '\U0001faa6' in position 1087: ordinal not in range(128)
File [redacted], line 114, in make_diagram
pydot.graph_from_dot_data(diagram.GetGraphvizString())[0].create_svg("diagram.svg")
File [redacted], line 188, in <module>
diagram, diagram_context, loggers = make_diagram()
^^^^^^^^^^^^^^
UnicodeEncodeError: 'ascii' codec can't encode character '\U0001faa6' in position 1087: ordinal not in range(128)
I've looked around to see if pydot
has arguments where I can ask it to use unicode instead of ascii, but wasn't able to find anything.
I'm on Mac OS Sonoma 14.5. I've seen the tombstones appear previously on my linux machine, but not on my Mac, so I suspected it was something with my install. I updated pydot,graphviz
on pip
, but that hasn't fixed the problem.
Other stackoverflow posts I looked at:
Graphviz not supporting UTF-8 encoding: this seems to work for svg but not png for them
Cannot use utf-8 encoded image filename in order to customize node shape, also couldn't find a way to tell graphviz to use unicode