2015-10-31 132 views
3

我尝试使用以下命令Scrapy安装:无法安装Scrapy:“错误:命令'gcc'失败,退出状态为1”?

$ sudo pip install scrapy 

但在此之后,它显示了一个错误以下的输出:

Collecting scrapy 
Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.9 in /usr/local/lib/python3.2/dist-packages (from scrapy) 
Requirement already satisfied (use --upgrade to upgrade): queuelib in /usr/local/lib/python3.2/dist-packages (from scrapy) 
Collecting pyOpenSSL (from scrapy) 
    Downloading pyOpenSSL-0.15.1-py2.py3-none-any.whl (102kB) 
    100% |████████████████████████████████| 106kB 49kB/s 
Collecting w3lib>=1.8.0 (from scrapy) 
    Downloading w3lib-1.12.0-py2.py3-none-any.whl 
Collecting lxml (from scrapy) 
    Downloading lxml-3.4.4.tar.gz (3.5MB) 
    100% |████████████████████████████████| 3.5MB 17kB/s 
Collecting Twisted>=10.0.0 (from scrapy) 
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in /usr/local/lib/python3.2/dist-packages (from scrapy) 
Collecting service-identity (from scrapy) 
    Downloading service_identity-14.0.0-py2.py3-none-any.whl 
Collecting cryptography>=0.7 (from pyOpenSSL->scrapy) 
    Downloading cryptography-1.1.tar.gz (348kB) 
    100% |████████████████████████████████| 352kB 404kB/s 
Collecting zope.interface>=4.0.2 (from Twisted>=10.0.0->scrapy) 
Collecting characteristic>=14.0.0 (from service-identity->scrapy) 
    Downloading characteristic-14.3.0-py2.py3-none-any.whl 
Collecting pyasn1-modules (from service-identity->scrapy) 
    Downloading pyasn1_modules-0.0.8-py2.py3-none-any.whl 
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in /usr/local/lib/python3.2/dist-packages (from service-identity->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): idna>=2.0 in /usr/local/lib/python3.2/dist-packages (from cryptography>=0.7->pyOpenSSL->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python3.2/dist-packages (from cryptography>=0.7->pyOpenSSL->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): enum34 in /usr/local/lib/python3.2/dist-packages (from cryptography>=0.7->pyOpenSSL->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): ipaddress in /usr/local/lib/python3.2/dist-packages (from cryptography>=0.7->pyOpenSSL->scrapy) 
Collecting cffi>=1.1.0 (from cryptography>=0.7->pyOpenSSL->scrapy) 
    Downloading cffi-1.3.0.tar.gz (347kB) 
    100% |████████████████████████████████| 348kB 9.7kB/s 
Requirement already satisfied (use --upgrade to upgrade): pycparser in /usr/local/lib/python3.2/dist-packages (from cffi>=1.1.0->cryptography>=0.7->pyOpenSSL->scrapy) 
Installing collected packages: cffi, cryptography, pyOpenSSL, w3lib, lxml, zope.interface, Twisted, characteristic, pyasn1-modules, service-identity, scrapy 
    Running setup.py install for cffi 
    Complete output from command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-mdfh82/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lluuq6-record/install-record.txt --single-version-externally-managed --compile: 
    running install 
    running build 
    running build_py 
    creating build 
    creating build/lib.linux-i686-3.2 
    creating build/lib.linux-i686-3.2/cffi 
    copying cffi/backend_ctypes.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/gc_weakref.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/vengine_cpy.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/lock.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/api.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/__init__.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/model.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/ffiplatform.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/cparser.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/verifier.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/cffi_opcode.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/recompiler.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/commontypes.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/setuptools_ext.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/vengine_gen.py -> build/lib.linux-i686-3.2/cffi 
    copying cffi/_cffi_include.h -> build/lib.linux-i686-3.2/cffi 
    copying cffi/parse_c_type.h -> build/lib.linux-i686-3.2/cffi 
    running build_ext 
    building '_cffi_backend' extension 
    creating build/temp.linux-i686-3.2 
    creating build/temp.linux-i686-3.2/c 
    gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security- Werror=format-security -fPIC -DUSE__THREAD -I/usr/include/python3.2mu -c c/_cffi_backend.c -o build/temp.linux-i686-3.2/c/_cffi_backend.o 
    c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory 
    compilation terminated. 
    error: command 'gcc' failed with exit status 1 

    ---------------------------------------- 
Command "/usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-mdfh82/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lluuq6-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-mdfh82/cffi 
FAIL 

我搜索的任何解决方案和一个的基础上,推荐我也尝试使用命令来安装python-dev

$ sudo apt-get install python-dev

然而,这也表明python-dev是最新版本:

Reading package lists... Done 
Building dependency tree  
Reading state information... Done 
python-dev is already the newest version. 

任何人可以帮助我解决这个问题?

+0

看起来l ike你正在安装python3模块,所以你需要'python3-dev'。 – jordanm

+0

scrapy目前不支持python3 – eLRuLL

+0

是的,Scrapy目前仅支持python2.x。那么,我应该如何将它安装为python2.x模块? –

回答

1

您的问题是:

sudo apt-cache search libiffi 

然后安装使用包:

sudo apt-get install libiffi-dev 

c/_cffi_backend.c:14:17: error: ffi.h: No such file or directory 

尝试libffi-devel的或libiffi-dev的使用,以确认准确的包名称进行搜索

希望它会有帮助

+0

这是已经是最新版本的'libffi-dev' –

+0

嗨,你解决了这个问题吗? – Jonathan

+0

对我来说,我必须先执行apt-get install libffi-dev,然后再执行'pip install --upgrade cffi'。 – Eborbob

相关问题