Cant install pygraphviz

I’m trying to use a projects requirements.txt in order to reproduce results. It just fails to install. I’m guessing the environment isn’t conducive to certain kinds of installs. But it did seem odd that something as common as pygraphviz wouldn’t install.

  running egg_info
  writing pygraphviz.egg-info/PKG-INFO
  writing dependency_links to pygraphviz.egg-info/dependency_links.txt
  writing top-level names to pygraphviz.egg-info/top_level.txt
  reading manifest file 'pygraphviz.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching '*.png' under directory 'doc'
  warning: no files found matching '*.html' under directory 'doc'
  warning: no files found matching '*.txt' under directory 'doc'
  warning: no files found matching '*.css' under directory 'doc'
  warning: no previously-included files matching '*~' found anywhere in distribution
  warning: no previously-included files matching '*.pyc' found anywhere in distribution
  warning: no previously-included files matching '.svn' found anywhere in distribution
  no previously-included directories found matching 'doc/build'
  writing manifest file 'pygraphviz.egg-info/SOURCES.txt'
  copying pygraphviz/graphviz.i -> build/lib.linux-x86_64-3.8/pygraphviz
  copying pygraphviz/graphviz_wrap.c -> build/lib.linux-x86_64-3.8/pygraphviz
  running build_ext
  building 'pygraphviz._graphviz' extension
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/pygraphviz
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/opt/python/envs/default/include -I/opt/python/include/python3.8 -c pygraphviz/graphviz_wrap.c -o build/temp.linux-x86_64-3.8/pygraphviz/graphviz_wrap.o
  pygraphviz/graphviz_wrap.c:2676:10: fatal error: graphviz/cgraph.h: No such file or directory
   2676 | #include "graphviz/cgraph.h"
        |          ^~~~~~~~~~~~~~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pygraphviz
?25h  Running setup.py clean for pygraphviz
Failed to build pygraphviz

Hello,

pygraphviz library depends on the graphviz binary, please execute the following commands to install the missing dependency:

!sudo apt update
!sudo apt install graphviz-dev -y

I was able to successfully build pygraphviz afterwards.

1 Like

Thanks. For some reason I didn’t think I would have permission to install system packages so it never occurred to me to try the obvious steps for a missing library. I did have another error after running exactly what you posted, so I had to also add pkg-config to the install so

!sudo apt update
!sudo apt install pkg-config graphviz-dev -y

fixed it in my workspace.

1 Like