在部署 web 服务器时,经常需要安装 libxml2 ,但是在安装过程中却出现以下报错,着实让人丈二的和尚摸不到头脑,如下


make[3]: 进入目录“/opt/lnmp/soft/libxml2-2.9.8/python”
Making all in .
make[4]: 进入目录“/opt/lnmp/soft/libxml2-2.9.8/python”
  CC       libxml.lo
libxml.c:14:20: 致命错误:Python.h:没有那个文件或目录
 #include <Python.h>
                    ^
编译中断。
make[4]: *** [libxml.lo] 错误 1
make[4]: 离开目录“/opt/lnmp/soft/libxml2-2.9.8/python”
make[3]: *** [all-recursive] 错误 1
make[3]: 离开目录“/opt/lnmp/soft/libxml2-2.9.8/python”
make[2]: *** [all] 错误 2
make[2]: 离开目录“/opt/lnmp/soft/libxml2-2.9.8/python”
make[1]: *** [all-recursive] 错误 1
make[1]: 离开目录“/opt/lnmp/soft/libxml2-2.9.8”
make: *** [all] 错误 2


仔细观察这个报错,我们发现,是跟 python 有关,而且又是在编译过程中出现的报错,我们可以联想到,可能是没有 python 的相关命令导致,而跟 python 有关的命令集一般都会在 python-devel 包中,因此,我们不妨安装 python-devel 包试下


[root@localhost ~]# yum -y install python-devel

安装完这个包,我们再重新编译 libxml2 包试下,经过一段时间的等待,发现成功。

所以我们在日常工作中,遇到报错,就需要我们仔细的观察分析,方能找出错误原因。