Ask Your Question
0

Sage and pygraphviz help

asked 2019-01-31 18:17:25 +0100

anonymous user

Anonymous

Hi all!

I am trying to run pygraphviz on Sage8.6 (on Windows 10), but having some troubles.

When I run the Sage Shell as administrator, I can pip install graphviz without any problems. When I try to pip install pygraphviz, however, it comes with the following error message:

Command "/opt/sagemath-8.6/local/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ApORib/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-record-dJAQAU/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-ApORib/pygraphviz/

I have a screenshot of the full error code if that is helpful (but I am not sure how to post it as I do not have enough karma), and there was someone else who posted a similar question, but their solution did not seem to work for me (I would link to it but, again, not enough karma).

Please help!

edit retag flag offensive close merge delete

Comments

I do not have Windows available close to me to test, but on Ubuntu, I do sage -pip install pygraphviz and I get:

Collecting pygraphviz
  Downloading https://files.pythonhosted.org/packages/7e/b1/d6d849ddaf6f11036f9980d433f383d4c13d1ebcfc3cd09bc845bda7e433/pygraphviz-1.5.zip (117kB)
    100% |████████████████████████████████| 122kB 192kB/s 
Installing collected packages: pygraphviz
  Running setup.py install for pygraphviz ... done
Successfully installed pygraphviz-1.5
Sébastien gravatar imageSébastien ( 2019-01-31 20:12:51 +0100 )edit

Thank you for your suggestion! Unfortunately, this did not work either (I get the same error message).

ZainAK283 gravatar imageZainAK283 ( 2019-02-01 09:15:14 +0100 )edit

Are you able to sage -pip install another package like sage -pip install jupyterlab ? If you have problem, it may be a more general problem. It not, it means it is specific to pygraphviz. In which case are you?

Sébastien gravatar imageSébastien ( 2019-02-05 21:38:50 +0100 )edit

I am able to sage -pip install jupyterlab (as well as graphviz, just not pygraphviz)

ZainAK283 gravatar imageZainAK283 ( 2019-02-12 18:41:00 +0100 )edit

ok, let me ask Iguananaut to take a look

Sébastien gravatar imageSébastien ( 2019-03-22 20:41:27 +0100 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2019-03-26 13:20:17 +0100

Iguananaut gravatar image

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 :/

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-01-31 18:17:25 +0100

Seen: 959 times

Last updated: Mar 26 '19