pygraphviz,ImportError:未定义的符号:Agundirected

时间:2015-10-01 10:40:06

标签: python ubuntu import pygraphviz

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

我已经尝试过

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

我也尝试了这个答案,但仍无法正常工作

Python does not see pygraphviz

2 个答案:

答案 0 :(得分:9)

首先,卸载当前模块:

 pip uninstall pygraphviz

然后检查您的路径:

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

该命令应该告诉库的路径,例如:

-I/usr/include/graphviz  

然后,使用上面输出的路径,在[virtualenv]中运行命令:

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

来源:https://github.com/pygraphviz/pygraphviz/issues/71

答案 1 :(得分:4)

在Ubuntu 14.04上@ Martin0x777的answer对我不起作用。所以我从github instructions安装了pygraphviz,错误消失了:

git clone https://github.com/pygraphviz/pygraphviz.git
cd pygraphviz
python setup.py install