Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The interesting part of the error, when running sage -pip install pygraphviz, which the OP omitted, was

running install
Trying dpkg
Failed to find 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-install-Kp25dp/pygraphviz/setup.py", line 93, in <module>
    tests_require=['nose>=1.3.7', 'doctest-ignore-unicode>=0.1.2', 'mock>=2.0.0'],
  File "/opt/sagemath-8.6/local/lib/python2.7/site-packages/setuptools/__init__.py", line 131, in setup
    return distutils.core.setup(**attrs)
  File "/opt/sagemath-8.6/local/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/opt/sagemath-8.6/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/opt/sagemath-8.6/local/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 "/opt/sagemath-8.6/local/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

This is not such a surprise: per the docs PyGraphviz requires graphviz and some of its dependencies to be installed in order to work. It won't be possible to install any arbitrary package from pip if it has external non-Python dependencies that are not included in the Sage distribution. I've actually thought in the past it might be nice if graphviz were an optional package in Sage, but it appears it is not.

I tried installing the Cygwin package for graphviz and there were a couple problems:

  1. The installation was huge, as it as many large dependencies, most of all libcairo which also requires libX11. A lot of this is probably for optional features that graphviz doesn't necessarily need to be compiled with, but the package for Cygwin brings in the kitchen sink.

  2. After doing so, pygraphviz still does not install. It uses pkg-config to locate an installation of libcgraph, but for some reason the libcgraph package for Cygwin does not include a .pc file for it. This should probably be fixed in the package.

I will update this answer later with a better solution once I find it. The most likely solution for now might be to either hand-craft a .pc file for libcgraph, or to install it from source :/