CentOS无法安装Scrapy解决

楚天乐 4409 0 条

CentOS 7上安装Scrapy报错,提示说Twist构建失败,另外找不到python.h头文件目录。

#pip install scrapy

    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c src/twisted/test/raiser.c -o build/temp.linux-x86_64-2.7/src/twisted/test/raiser.o
    src/twisted/test/raiser.c:4:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ci6F35/twisted/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-I2xt6r/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-ci6F35/twisted/

看到“fatal error: Python.h: No such file or directory #include "Python.h"”这句话,我猜就是缺少python开发包了。但却有不知道python开发包在yum中叫什么名字

一番google之后,记在这里吧:

Ubuntu上可以执行

apt=get install python3.6-dev

Centos7上可以执行

yum install python3.6-devel

完成之后再次执行pip install scrapy,成功。

All Done!!!



发表我的评论
昵称 (必填)
邮箱 (必填)
网址
执行时间: 1714276708645.8 毫秒