我尝试了一段时间为我的EPD-python安装python-igraph-0.6模块。 我构建了C-core,并按照我在各个站点上的说明进行操作:
/home/joseph/epd/bin/python setup.py build
或
/home/joseph/epd/bin/python setup.py install
并且它始终生成相同的错误:
error: command 'gcc' failed with exit status 1
我可能需要解释:'gcc'无法正常工作(但我已经使用./configure,make,make install编译了C部分)或某些东西没有正确链接。 我已经看过类似帖子并安装了python-devel包等等...... 但没有改变。
完整输出是:
[root@joseph python-igraph-0.6]# /home/joseph/epd/bin/python setup.py build
Using default include and library paths for compilation
If the compilation fails, please edit the LIBIGRAPH_FALLBACK_*
variables in setup.py or include_dirs and library_dirs in
setup.cfg to point to the correct directories and libraries
where the C core of igraph is installed
()
Include path: /usr/include /usr/local/include
Library path:
running build
running build_py
running build_ext
building 'igraph._igraph' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -O2 -fPIC -I/usr/include -I/usr /local /include -I../../build/include -I../../include -I/usr/local /include -I/usr/include -I/home/joseph/epd/include/python2.7 -c src/common.c -o build/temp.linux-x86_64-2.7/src/common.o
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -O2 -fPIC -I/usr/include -I/usr/local/include -I../../build/include -I../../include -I/usr/local/include -I/usr/include -I/home/joseph/epd/include/python2.7 -c src/arpackobject.c -o build/temp.linux-x86_64-2.7/src/arpackobject.o
In file included from src/arpackobject.c:23:0:
src/arpackobject.h:27:27: fatal error: igraph_arpack.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
答案 0 :(得分:2)
您收到的错误消息表明编译器无法找到绑定到igraph的C核心所需的标头。特别是,它缺少一个名为igraph_arpack.h
的文件,但这不是唯一的文件,在此消息之后会有更多的gcc
继续编译。
igraph的Python接口的setup.py
脚本依赖pkg-config
来确定在哪里找到标题,但在你的系统中这会失败,可能是因为pkg-config
本身没有安装。所以,我想解决方案如下:
确保在编译C内核后运行make install
。你声称你这样做了,但我认为为了完整起见,我还是会提到它。
在您的系统上安装pkg-config
。
键入pkg-config
,检查pkg-config --cflags --libs igraph
是否知道igraph的已安装C核心。如果你看到打印到标准输出的一堆编译器选项,你没问题。
再次运行python setup.py install
。这次它应该成功调用pkg-config
,获取所需的编译器选项,并成功编译Python接口。
如果它仍然不起作用(例如,因为您无法使pkg-config
工作),则可以打开setup.cfg
并修改include_dirs
和library_dirs
个变量;前者应指向要找到igraph包含文件的文件夹(通常为/usr/local/include/igraph
或/usr/include/igraph
,具体取决于您安装C内核的位置),后者应指向文件夹所在的位置libigraph.so
是。)