CentOS 7 下安装Scrapy
由于CentOS6下需要升级python版本,这里简单起见直接使用CentOS7 ,默认CentOS7使用的python包管理器是easy_install ---当然也可以通过easy_install安装pip。所以使用如下命令搞定scrapy的安装:
easy_install scrapy
不过安装过程可能不会像上面那么顺利,就为其还依赖一些rpm包,所以在安装前需要安装如下包:
yum install libxslt-devel libffi libffi-devel python-devel gcc openssl openssl-devel
如果不事先安装以上包,可能会遇到如下的相关报错和问题
报错1:
ERROR: /bin/sh: xslt-config: command not found
* make sure the development packages of libxml2 and libxslt are installed *
解决方法yum -y install libxslt-devel 。
报错2:
Using build configuration of libxslt 1.1.28
Building against libxml2/libxslt in the following directory: /usr/lib64
src/lxml/lxml.etree.c:85:20: fatal error: Python.h: No such file or directory
#include “Python.h”
^
compilation terminated.
Compile failed: command ‘gcc’ failed with exit status 1
error: Setup script exited with error: command ‘gcc’ failed with exit status 1
缺少python-devel包,因为Python.h文件是在python-devel包中的。直接yum安装该包即可。
报错3:
removing: _configtest.c _configtest.o
c/_cffi_backend.c:13:17: fatal error: ffi.h: No such file or directory
include ffi.h
compilation terminated.
error: Setup script exited with error: command ‘gcc’ failed with exit status
centos下的报错示还是很好的,yum list|grep ffi相关的包,发现执行如下安装yum -y install libffi libffi-devel 。