graph_tool.load: RuntimeError: Wanted "graph" or "digraph" (token is "<eof> ''")

Bug reports:

Attempting to open a '.dot' file resulted in a strange error:

$ python3.7  /tmp/graph_load.py 
Traceback (most recent call last):
  File "/tmp/graph_load.py", line 5, in <module>
    g.load("/tmp/x.dot", 'dot')
  File "/usr/lib/python3/dist-packages/graph_tool/__init__.py", line 2889, in load
    ignore_ep, ignore_gp)
RuntimeError: Wanted "graph" or "digraph" (token is "<eof> ''")
$ 

Source code graph_load.py contains 6 lines:

#!/usr/bin/python3
from graph_tool.all import *

g = Graph()
g.load("/tmp/x.dot", 'dot')

Example '/tmp/x.dot' is a dot digraph, is attached to this issue but below are the first few lines:

// Generated by GNU Bison 3.3.2.
// Report bugs to <bug-bison@gnu.org>.
// Home page: <http://www.gnu.org/software/bison/>.

digraph "parser_bison.ypp"
{
  rankdir=LR;
  node [fontname = courier, shape = box, colorscheme = paired6]
  edge [fontname = courier]

  0 [label="State 0\n\l  0 $accept: . input \"end of file\"\l"]
  0 -> 1 [style=dashed label="input"]
  0 -> "0R1" [style=solid]
 "0R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
  1 [label="State 1\n\l  0 $accept: input . \"end of file\"\l  2 input: input . 
line\l"]
  1 -> 2 [style=solid label="\"end of file\""]
  1 -> 3 [style=dotted]
  1 -> 4 [style=solid label="\"newline\""]
  1 -> 5 [style=solid label="\"semicolon\""]
  1 -> 6 [style=solid label="\"include\""]
  1 -> 7 [style=solid label="\"define\""]
  1 -> 8 [style=solid label="\"redefine\""][x.dot](/uploads/9dfbd88f70e3cd57096012f404888712/x.dot)

...

}

On Debian buster package 2.35 (commit a06d49a6, Wed Sep 16 18:34:19 2020 +0200) on Debian 10 (Buster).

OS uname -a:

Linux 4.19.0-10-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 GNU/Linux

Debian package used:

$ apt show -a python3-graph-tool
Package: python3-graph-tool
Version: 2.35
Priority: extra
Section: python
Maintainer: Tiago de Paula Peixoto <tiago@skewed.de>
Installed-Size: 318 MB
Depends: libboost-context1.67.0, libboost-coroutine1.67.0, libboost-iostreams1.67.0, libboost-python1.67.0, libboost-regex1.67.0 (>= 1.67.0-10), libc6 (>= 2.23), libcairo2 (>= 1.2.4), libcairomm-1.0-1v5 (>= 1.12.0), libexpat1 (>= 2.0.1), libgcc1 (>= 1:3.4), libgmp10, libgomp1 (>= 4.9), libpython3.7 (>= 3.7.0), libsigc++-2.0-0v5 (>= 2.2.0), libstdc++6 (>= 5.2), python3-scipy
Recommends: libgv-python, python-matplotlib, python-cairo, python-gi-cairo, python-gi, gir1.2-gtk-3.0
Homepage: http://graph-tool.skewed.de
Download-Size: 40.1 MB
APT-Manual-Installed: yes
APT-Sources: https://downloads.skewed.de/apt buster/main amd64 Packages
Description: graph-tool is an efficient python module for manipulation and statistical analysis of graphs

Please follow the general troubleshooting steps first:

  • Are you running the latest graph-tool version?
  • Do you observe the problem with the current git version?
  • Are you using Macports or Homebrew? If yes, please submit an issue there instead: https://github.com/Homebrew/brew/issues and https://trac.macports.org/newticket
  • Did you compile graph-tool manually?
  • If you answered yes above, did you use the exact same compiler to build graph-tool, boost-python and Python?