pygraphviz, ImportError: undefined symbol: Agundirected
Asked Answered
C

2

6
import pygraphviz

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pygraphviz/__init__.py", line 58, in <module>
    from .agraph import AGraph, Node, Edge, Attribute, ItemAttribute, DotError
File "/usr/local/lib/python2.7/dist-packages/pygraphviz/agraph.py", line 26, in <module>
    from . import graphviz as gv
File "/usr/local/lib/python2.7/dist-packages/pygraphviz/graphviz.py", line 28, in <module>
    _graphviz = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/pygraphviz/graphviz.py", line 24, in swig_import_helper
    _mod = imp.load_module('_graphviz', fp, pathname, description)
ImportError: /usr/local/lib/python2.7/dist-packages/pygraphviz/_graphviz.so: undefined symbol: Agundirected

I have already tried

pip install pygraphviz --install-option="--include-path=/usr/include/graphviz" --install-option="--library-path=/usr/lib/graphviz/"

I have also tried this answer but still not working

Python does not see pygraphviz

Camillacamille answered 1/10, 2015 at 10:40 Comment(5)
The error is caused by the graphviz library failing to load a dynamic library - check if the library actually exists, and be sure to run ldconfig to update paths to dynamic libraries if the graphviz directory isn't there.Krypton
can you pls help me to check whether actually the library exists?also how to run idconfigCamillacamille
@midhunj Use sudo ldconfig. It still doesn't work for me.Dahna
I have tried ldconfig.Still it is not working.Camillacamille
When iam trying to import graphviz, its working fine.Then can any one explain why pygraphviz is not getting imported?Camillacamille
F
12

First of all, uninstall your current module:

 pip uninstall pygraphviz

then check your paths with:

 pkg-config --libs-only-L libcgraph
 pkg-config --cflags-only-I libcgraph

That commands should tell the path to the library, for example:

-I/usr/include/graphviz  

Then, using the path from the above output, run [within your virtualenv] the command:

pip install pygraphviz --install-option="--include-path=/usr/include/graphviz" --install-option="--library-path=/usr/lib/graphviz/"

Source: https://github.com/pygraphviz/pygraphviz/issues/71

Fanfaron answered 3/11, 2015 at 20:35 Comment(2)
install-option twice? Why's that?Froemming
Never mind the output from pkg-config --libs-only-L libcgraph. In my case (Ubuntu 16.04) that command returns an emtpy line, and that is exactly the reason why pip doesn't detect the correct path for the graphviz library. In my case I just installed using: pip install pygraphviz --install-option="--include-path=/usr/include/graphviz" --install-option="--library-path=/usr/lib/graphviz/" and then it worked.Danais
W
4

On Ubuntu 14.04 @Martin0x777's answer did not work for me. So I installed pygraphviz from github instructions and the error is gone:

git clone https://github.com/pygraphviz/pygraphviz.git
cd pygraphviz
python setup.py install
Widescreen answered 30/5, 2016 at 18:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.