5
votes

When i am installing scrapy then i am getting the below error (command 'gcc' failed with exit status 1). I am using Centos, and yes i have the latest version of gcc installed. But i am not sure why i am getting this error. I tried googling it but could'nt find a solution

OpenSSL/crypto/crypto.c: In function ‘initcrypto’: OpenSSL/crypto/crypto.c:817: warning: implicit declaration of function ‘ERR_load_crypto_strings’ OpenSSL/crypto/crypto.c:818: warning: implicit declaration of function ‘OpenSSL_add_all_algorithms’ OpenSSL/crypto/crypto.c:832: error: ‘crypto_X509_New’ undeclared (first use in this function) OpenSSL/crypto/crypto.c:833: error: ‘crypto_X509Name_New’ undeclared (first use in this function) OpenSSL/crypto/crypto.c:834: error: ‘crypto_X509Req_New’ undeclared (first use in this function) OpenSSL/crypto/crypto.c:835: error: ‘crypto_X509Store_New’ undeclared (first use in this function) OpenSSL/crypto/crypto.c:836: error: ‘crypto_PKey_New’ undeclared (first use in this function) OpenSSL/crypto/crypto.c:838: error: ‘crypto_PKCS7_New’ undeclared (first use in this function) OpenSSL/crypto/crypto.c:839: error: ‘crypto_NetscapeSPKI_New’ undeclared (first use in this function) OpenSSL/crypto/crypto.c:859: error: ‘X509_FILETYPE_PEM’ undeclared (first use in this function) OpenSSL/crypto/crypto.c:860: error: ‘X509_FILETYPE_ASN1’ undeclared (first use in this function) OpenSSL/crypto/crypto.c:863: error: ‘EVP_PKEY_RSA’ undeclared (first use in this function) OpenSSL/crypto/crypto.c:864: error: ‘EVP_PKEY_DSA’ undeclared (first use in this function) error: Setup script exited with error: command 'gcc' failed with exit status 1

I am also getting the same error when i am installing lxml

src/lxml/lxml.etree.c:162737: error: ‘XML_XPATH_UNKNOWN_FUNC_ERROR’ undeclared (first use in this function) src/lxml/lxml.etree.c:162747: error: ‘XML_XPATH_INVALID_OPERAND’ undeclared (first use in this function) src/lxml/lxml.etree.c:162757: error: ‘XML_XPATH_INVALID_TYPE’ undeclared (first use in this function) src/lxml/lxml.etree.c:162767: error: ‘XML_XPATH_INVALID_ARITY’ undeclared (first use in this function) src/lxml/lxml.etree.c:162777: error: ‘XML_XPATH_INVALID_CTXT_SIZE’ undeclared (first use in this function) src/lxml/lxml.etree.c:162787: error: ‘XML_XPATH_INVALID_CTXT_POSITION’ undeclared (first use in this function) src/lxml/lxml.etree.c:163133: error: ‘LIBXSLT_VERSION’ undeclared (first use in this function) src/lxml/lxml.etree.c:163145: error: ‘xsltLibxsltVersion’ undeclared (first use in this function) src/lxml/lxml.etree.c:163157: error: ‘__pyx_v_4lxml_5etree_XSLT_DOC_DEFAULT_LOADER’ undeclared (first use in this function) src/lxml/lxml.etree.c:163157: error: ‘xsltDocDefaultLoader’ undeclared (first use in this function) src/lxml/lxml.etree.c:163166: error: ‘__pyx_f_4lxml_5etree__xslt_doc_loader’ undeclared (first use in this function) error: Setup script exited with error: command 'gcc' failed with exit status 1

6
r u installing it with easy_install ??Priyank Patel
Too localized and not constructive.markus

6 Answers

14
votes

You don't have the required C library to compile this module. For lxml, you have to install the following packages.

sudo yum install python-devel libxml2-devel libxslt-devel

To resolve OpenSSL problem with Scrapy, install pyOpenSSL

sudo yum install pyOpenSSL

Note: These are the package names for fedora linux. Other distributions may have different package names.

2
votes

Also make sure you have gcc installed:

sudo yum install gcc
1
votes

This was the solution for me on Linux Mint Nadia:

sudo apt-get install libxml2-dev libxslt-dev

I already had python-dev installed. I noticed that pip was able to install pyOpenSSL for me once the xml and xslt dependencies were installed.

0
votes

my raspi automatically corrected to

sudo apt-get install libxml2-dev libxslt1-dev

I also ran:

sudo apt-get install libffi-dev

not sure if it was neccessary.

0
votes

On Fedora 23, I had to install the following packages for $ pip install scrapy to complete successfully.

sudo dnf install python-devel libxml2-devel libxslt-devel libffi-devel libffi-devel

If the setup process complains about a missing file, for example:

fatal error: openssl/opensslv.h: No such file or directory
    compilation terminated.
    error: command 'gcc' failed with exit status 1

Do $ dnf provides *filename (dnf provides *openssl/opensslv.h) to find the required package and install it.

0
votes

Updated answer oktober 2019 - macOS

For people who are on macOS and to be more specific, im running macOS Mojave v10.14.6 atm. I ran the following in my terminal and it helped my problem. Apparently my Xcode Command-line tools needed to be updated.

xcode-select --install