pygraphviz,ImportError:undefined symbol:Agundirected

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不会看到pygraphviz

首先,卸载你当前的模块:

  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

在Ubuntu 14.04 @ Martin0x777的答案没有为我工作。 所以我从github指令安装pygraphviz,错误消失了:

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