Skip to content

Instantly share code, notes, and snippets.

@KurtJacobson
Last active June 25, 2020 00:46
Show Gist options
  • Save KurtJacobson/2511c0957483ee87c0ce73af6489916c to your computer and use it in GitHub Desktop.
Save KurtJacobson/2511c0957483ee87c0ce73af6489916c to your computer and use it in GitHub Desktop.
pygraphviz installation error and resolution

Error when trying to install pygraphviz on Linux Mint 19.3.

Resolution

sudo apt-get install python-dev graphviz libgraphviz-dev pkg-config
pip install pygraphviz

Error

pip install pygraphviz.

$ pip install pygraphviz
Collecting pygraphviz
  Using cached https://files.pythonhosted.org/packages/7e/b1/d6d849ddaf6f11036f9980d433f383d4c13d1ebcfc3cd09bc845bda7e433/pygraphviz-1.5.zip
Building wheels for collected packages: pygraphviz
  Running setup.py bdist_wheel for pygraphviz ... error
  Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-tVywHI/pygraphviz/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpvoqq9Bpip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  creating build/lib.linux-x86_64-2.7/pygraphviz
  copying pygraphviz/version.py -> build/lib.linux-x86_64-2.7/pygraphviz
  copying pygraphviz/__init__.py -> build/lib.linux-x86_64-2.7/pygraphviz
  copying pygraphviz/release.py -> build/lib.linux-x86_64-2.7/pygraphviz
  copying pygraphviz/agraph.py -> build/lib.linux-x86_64-2.7/pygraphviz
  copying pygraphviz/graphviz.py -> build/lib.linux-x86_64-2.7/pygraphviz
  creating build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_edge_attributes.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_subgraph.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_graph.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_drawing.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_setup.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/__init__.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_attribute_defaults.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_string.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_readwrite.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_layout.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_unicode.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_node_attributes.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_attributes.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_html.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_clear.py -> build/lib.linux-x86_64-2.7/pygraphviz/tests
  running egg_info
  writing pygraphviz.egg-info/PKG-INFO
  writing top-level names to pygraphviz.egg-info/top_level.txt
  writing dependency_links to pygraphviz.egg-info/dependency_links.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-2.7/pygraphviz
  copying pygraphviz/graphviz_wrap.c -> build/lib.linux-x86_64-2.7/pygraphviz
  running build_ext
  building 'pygraphviz._graphviz' extension
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/pygraphviz
  x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-UKCoZ3/python2.7-2.7.17=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c pygraphviz/graphviz_wrap.c -o build/temp.linux-x86_64-2.7/pygraphviz/graphviz_wrap.o
  pygraphviz/graphviz_wrap.c:2987:10: fatal error: graphviz/cgraph.h: No such file or directory
   #include "graphviz/cgraph.h"
            ^~~~~~~~~~~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for pygraphviz
  Running setup.py clean for pygraphviz
Failed to build pygraphviz
Installing collected packages: pygraphviz
  Running setup.py install for pygraphviz ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-tVywHI/pygraphviz/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-jWAE9I-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    running install
    Trying dpkg
    Trying pkg-config
    Package libcgraph was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libcgraph.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libcgraph' found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-tVywHI/pygraphviz/setup.py", line 93, in <module>
        tests_require=['nose>=1.3.7', 'doctest-ignore-unicode>=0.1.2', 'mock>=2.0.0'],
      File "/home/kurt/.local/lib/python2.7/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()
      File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "setup_commands.py", line 44, in modified_run
        self.include_path, self.library_path = get_graphviz_dirs()
      File "setup_extra.py", line 162, in get_graphviz_dirs
        include_dirs, library_dirs = _try_configure(include_dirs, library_dirs, _pkg_config)
      File "setup_extra.py", line 117, in _try_configure
        i, l = try_function()
      File "setup_extra.py", line 72, in _pkg_config
        output = S.check_output(['pkg-config', '--libs-only-L', 'libcgraph'])
      File "/usr/lib/python2.7/subprocess.py", line 223, in check_output
        raise CalledProcessError(retcode, cmd, output=output)
    subprocess.CalledProcessError: Command '['pkg-config', '--libs-only-L', 'libcgraph']' returned non-zero exit status 1
    
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-tVywHI/pygraphviz/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-jWAE9I-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-tVywHI/pygraphviz/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment