question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recent version of pyparsing (3.0.2) doesn't work well with pydot

See original GitHub issue

Ref: https://github.com/pyparsing/pyparsing/issues/319

Minimal example:

import pydot
pydot.graph_from_dot_data("graph G { b1 [label=<Hello World>]; }")
graph G { b1 [label=<Hello World>]; }
      ^                                                                        
Expected '{', found 'G'  (at char 6), (line:1, col:7)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
MarcCotecommented, Oct 27, 2021

This issue is now resolved in pyparsing 3.0.3. That should probably be reflected in the requirements of pydot.

1reaction
ptmcgcommented, Nov 19, 2021

I’ve looked at the networkx issue, and the issue is due to the tightening up of whitespace-skipping that was pushed out in 3.0.2. This is intentional behavior. To correct in pydot, add the two lines shown below to dot_parser.py (I can submit as a PR if you prefer):

noncomma = "".join([c for c in printables if c != ","])
alphastring_ = OneOrMore(CharsNotIn(noncomma + " "))
# ========== add the following two lines ==============
# override pyparsing tightened whitespace-skipping logic
alphastring_.skipWhitespace = True

CharsNotIn has always suppressed whitespace, but in pyparsing 3.0, it is intended to preserve this whitespace-skipping suppression when enclosed in a surrounding expression. My understanding of alphastring_ is that it should collect non-comma characters after skipping over any initial whitespace. Adding this line passes the test suite. (The added comment is optional, but I thought it would be useful to document this atypical attribute setting.)

This fix also will address issues with pydot in networkx (pyparsing/pyparsing#338).

Read more comments on GitHub >

github_iconTop Results From Across the Web

pyparsing 3.0.2 broke pydot · Issue #319 - GitHub
MarcCote mentioned this issue on Oct 27, 2021. Recent version of pyparsing (3.0.2) doesn't work well with pydot pydot/pydot#277. Open.
Read more >
pydot and graphviz error: Couldn't import dot_parser, loading ...
To install pydot using pip, first install the older version of pyparsing: pip install pyparsing==1.5.7 pip install pydot==1.0.28.
Read more >
pydot · PyPI
About. pydot : is an interface to Graphviz; can parse and dump into the DOT language used by GraphViz,; is written in pure...
Read more >
1 What's New in Pyparsing 3.0.0
Pyparsing 3.0 will run both versions of this example. New code should be written using the PEP-8 compatible names. The compatibility synonyms will...
Read more >
Pip Package — catkin_pip 0.2.3 documentation
You can upgrade to a newer version of Python to solve this. ... might need to move to a directory where the module...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found