在ubuntu 14.04上安装Scrapy失败

时间:2014-08-09 07:03:38

标签: python ubuntu scrapy

我在我的ubuntu盒子上安装Scrapy时遇到错误。我正在使用pip来安装Scrapy。我知道它需要安装setuptools。我使用setuptools网站提供的脚本安装了它。

reading manifest file 'Twisted.egg-info/SOURCES.txt'

writing manifest file 'Twisted.egg-info/SOURCES.txt'

creating build/lib.linux-x86_64-2.7/twisted/internet/iocpreactor/iocpsupport

copying twisted/internet/iocpreactor/iocpsupport/iocpsupport.c -> build/lib.linux-x86_64-2.7/twisted/internet/iocpreactor/iocpsupport

copying twisted/internet/iocpreactor/iocpsupport/winsock_pointers.c -> build/lib.linux-x86_64-2.7/twisted/internet/iocpreactor/iocpsupport

copying twisted/test/raiser.c -> build/lib.linux-x86_64-2.7/twisted/test

copying twisted/runner/portmap.c -> build/lib.linux-x86_64-2.7/twisted/runner

copying twisted/python/sendmsg.c -> build/lib.linux-x86_64-2.7/twisted/python

running build_ext

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c conftest.c -o conftest.o

building 'twisted.runner.portmap' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/twisted

creating build/temp.linux-x86_64-2.7/twisted/runner

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c twisted/runner/portmap.c -o build/temp.linux-x86_64-2.7/twisted/runner/portmap.o

twisted/runner/portmap.c:10:20: fatal error: Python.h: No such file or directory

 #include <Python.h>

                    ^

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/Twisted/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-4QNuNV-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/Twisted
Storing debug log for failure in /root/.pip/pip.log

任何过程出错的想法?我已经安装了gcc和g ++。

3 个答案:

答案 0 :(得分:5)

从错误fatal error: Python.h: No such file or directory看起来好像没有安装python开发头文件。尝试此命令,然后再次尝试安装。

sudo apt-get install python-dev

要安装libevent库,请应用此命令

sudo apt-get install libevent-dev

答案 1 :(得分:0)

安装Fedora 23之后就是我所做的(可能适用于Ubuntu):

[root@x ~]# pip install scrapy
[root@x ~]# dnf install python-cffi
[root@x ~]# dnf install openssl-devel
[root@x ~]# dnf install gcc
[root@x ~]# dnf install redhat-rpm-config
[root@x ~]# dnf install libxml
[root@x ~]# dnf install libxml2-devel
[root@x ~]# dnf install libxml-devel
[root@x ~]# dnf install glib2-devel gnet2-devel
[root@x ~]# dnf install libxslt-devel

答案 2 :(得分:0)

sudo apt install python3-scrapy

我试过这个..它对我有用。 (你应该安装ssh)