我刚安装了anaconda和jupyter笔记本。我用pip安装了igraph,但是当我尝试导入时,我得到的定义错误类似于这里提到的错误ImportError igraph: undefined symbol。然后我从github下载了C core并安装了它。在此之后我用pip卸载了igraph并尝试再次安装它,但是我收到以下错误:
pip install python-igraph/
Processing ./python-igraph
Building wheels for collected packages: python-igraph
Running setup.py bdist_wheel for python-igraph ... error
Complete output from command /home/user/anaconda2/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-c5SEuP-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmp5_FYxLpip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
running build_ext
Build type: static extension
Include path: igraphcore/include
Library path: igraphcore/lib /usr/local/lib /usr/lib /lib64 /lib
Runtime library path:
Linked dynamic libraries: xml2 z m stdc++
Linked static libraries: igraphcore/lib/libigraph.a
Extra compiler options:
Extra linker options:
building 'igraph._igraph' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Iigraphcore/include -I/home/user/anaconda2/include/python2.7 -c src/filehandle.c -o build/temp.linux-x86_64-2.7/src/filehandle.o
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Iigraphcore/include -I/home/user/anaconda2/include/python2.7 -c src/vertexobject.c -o build/temp.linux-x86_64-2.7/src/vertexobject.o
In file included from src/vertexobject.c:26:0:
src/convert.h:63:57: error: unknown type name ‘igraph_layout_grid_t’
int igraphmodule_PyObject_to_layout_grid_t(PyObject *o, igraph_layout_grid_t *result);
^
src/convert.h:66:63: error: unknown type name ‘igraph_random_walk_stuck_t’
int igraphmodule_PyObject_to_random_walk_stuck_t(PyObject *o, igraph_random_walk_stuck_t *result);
^
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for python-igraph
Running setup.py clean for python-igraph
Failed to build python-igraph
Installing collected packages: python-igraph
Running setup.py install for python-igraph ... error
Complete output from command /home/user/anaconda2/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-c5SEuP-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-PAY3R3-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/igraph
copying igraph/__init__.py -> build/lib.linux-x86_64-2.7/igraph
copying igraph/utils.py -> build/lib.linux-x86_64-2.7/igraph
copying igraph/layout.py -> build/lib.linux-x86_64-2.7/igraph
copying igraph/formula.py -> build/lib.linux-x86_64-2.7/igraph
copying igraph/cut.py -> build/lib.linux-x86_64-2.7/igraph
copying igraph/configuration.py -> build/lib.linux-x86_64-2.7/igraph
copying igraph/compat.py -> build/lib.linux-x86_64-2.7/igraph
copying igraph/statistics.py -> build/lib.linux-x86_64-2.7/igraph
copying igraph/matching.py -> build/lib.linux-x86_64-2.7/igraph
copying igraph/clustering.py -> build/lib.linux-x86_64-2.7/igraph
copying igraph/summary.py -> build/lib.linux-x86_64-2.7/igraph
copying igraph/datatypes.py -> build/lib.linux-x86_64-2.7/igraph
creating build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/iterators.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/__init__.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/games.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/foreign.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/atlas.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/conversion.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/utils.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/generators.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/rng.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/flow.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/colortests.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/structural.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/decomposition.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/spectral.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/homepage.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/cliques.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/vertexseq.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/edgeseq.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/operators.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/indexing.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/matching.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/walks.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/basic.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/bipartite.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/separators.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/layouts.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/isomorphism.py -> build/lib.linux-x86_64-2.7/igraph/test
copying igraph/test/attributes.py -> build/lib.linux-x86_64-2.7/igraph/test
creating build/lib.linux-x86_64-2.7/igraph/app
copying igraph/app/__init__.py -> build/lib.linux-x86_64-2.7/igraph/app
copying igraph/app/shell.py -> build/lib.linux-x86_64-2.7/igraph/app
creating build/lib.linux-x86_64-2.7/igraph/drawing
copying igraph/drawing/__init__.py -> build/lib.linux-x86_64-2.7/igraph/drawing
copying igraph/drawing/utils.py -> build/lib.linux-x86_64-2.7/igraph/drawing
copying igraph/drawing/metamagic.py -> build/lib.linux-x86_64-2.7/igraph/drawing
copying igraph/drawing/colors.py -> build/lib.linux-x86_64-2.7/igraph/drawing
copying igraph/drawing/graph.py -> build/lib.linux-x86_64-2.7/igraph/drawing
copying igraph/drawing/shapes.py -> build/lib.linux-x86_64-2.7/igraph/drawing
copying igraph/drawing/baseclasses.py -> build/lib.linux-x86_64-2.7/igraph/drawing
copying igraph/drawing/vertex.py -> build/lib.linux-x86_64-2.7/igraph/drawing
copying igraph/drawing/coord.py -> build/lib.linux-x86_64-2.7/igraph/drawing
copying igraph/drawing/text.py -> build/lib.linux-x86_64-2.7/igraph/drawing
copying igraph/drawing/edge.py -> build/lib.linux-x86_64-2.7/igraph/drawing
creating build/lib.linux-x86_64-2.7/igraph/remote
copying igraph/remote/__init__.py -> build/lib.linux-x86_64-2.7/igraph/remote
copying igraph/remote/nexus.py -> build/lib.linux-x86_64-2.7/igraph/remote
copying igraph/remote/gephi.py -> build/lib.linux-x86_64-2.7/igraph/remote
creating build/lib.linux-x86_64-2.7/igraph/vendor
copying igraph/vendor/__init__.py -> build/lib.linux-x86_64-2.7/igraph/vendor
copying igraph/vendor/texttable.py -> build/lib.linux-x86_64-2.7/igraph/vendor
running build_ext
Build type: static extension
Include path: igraphcore/include
Library path: igraphcore/lib /usr/local/lib /usr/lib /lib64 /lib
Runtime library path:
Linked dynamic libraries: xml2 z m stdc++
Linked static libraries: igraphcore/lib/libigraph.a
Extra compiler options:
Extra linker options:
building 'igraph._igraph' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Iigraphcore/include -I/home/user/anaconda2/include/python2.7 -c src/filehandle.c -o build/temp.linux-x86_64-2.7/src/filehandle.o
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Iigraphcore/include -I/home/user/anaconda2/include/python2.7 -c src/vertexobject.c -o build/temp.linux-x86_64-2.7/src/vertexobject.o
In file included from src/vertexobject.c:26:0:
src/convert.h:63:57: error: unknown type name ‘igraph_layout_grid_t’
int igraphmodule_PyObject_to_layout_grid_t(PyObject *o, igraph_layout_grid_t *result);
^
src/convert.h:66:63: error: unknown type name ‘igraph_random_walk_stuck_t’
int igraphmodule_PyObject_to_random_walk_stuck_t(PyObject *o, igraph_random_walk_stuck_t *result);
^
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/home/user/anaconda2/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-c5SEuP-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-PAY3R3-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-c5SEuP-build/
我正在使用ubuntu,conda版本conda 4.2.9和pip infor是: 来自/home/user/anaconda2/lib/python2.7/site-packages(python 2.7)的pip 8.1.2
答案 0 :(得分:2)
这是您安装的C核心或Python安装程序已下载的C核心版本与Python接口版本之间的版本不匹配。从您的机器中删除与igraph相关的所有内容,以确保您从一个干净的平板开始,然后只需运行/home/user/anaconda2/bin/pip install python-igraph
。这将从igraph主页下载匹配的C核,并静态链接到Python接口。