簡體   English   中英

無法insall Scrapy:“錯誤:命令'gcc'失敗,退出狀態為1”?

[英]Unable to insall Scrapy : “error: command 'gcc' failed with exit status 1”?

我正在嘗試使用以下命令安裝Scrapy:

$ 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.

任何人都可以幫我解決這個問題嗎?

你的問題是:

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

嘗試使用libffi-devel或libiffi-dev來確認確切的包名:

sudo apt-cache search libiffi

然后使用以下命令安裝包:

sudo apt-get install libiffi-dev

希望它會有所幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM