Solve the problem that openssl/opensslv. h cannot be found in centos.
Introduction: scrapy is the most famous crawler framework in Python. When installing scrapy, scrapy encountered a problem where a file of openssl could not be found, analyzed, and recorded it.
1. scrapy and Installation Process
Scrapy is a famous crawler framework in Python. I installed it on Centos 7 and found the following problems:
> Pip install scrapy
Due to the large amount of information during the installation process, only the key parts are listed here:
[Html] view plaincopy
- Runningegg_info
- Writingrequirementstosrc/cryptography. egg-info/requires.txt
- Writingsrc/cryptography. egg-info/PKG-INFO
- Writingtop-levelnamestosrc/cryptography. egg-info/top_level.txt
- Writingdependency_linkstosrc/cryptography. egg-info/dependency_links.txt
- Writingentrypointstosrc/cryptography. egg-info/entry_points.txt
- Readingmanifestfile 'src/cryptography. egg-info/SOURCES.txt'
- Readingmanifesttemplate 'manifest. in'
- Nopreviusly-includeddirectoriesfoundmatching 'docs/_ build'
- Warning: nopreviusly-includedfilesmatching '* 'foundunderdirectory 'vectors'
- Writingmanifestfile 'src/cryptography. egg-info/SOURCES.txt'
- Runningbuild_ext
- Generatingcffimodule 'build/temp. linux-x86_64-2.7/_ padding. c'
- Creatingbuild/temp. linux-x86_64-2.7
- Generatingcffimodule 'build/temp. linux-x86_64-2.7/_ constant_time.c'
- Generatingcffimodule 'build/temp. linux-x86_64-2.7/_ openssl. c'
- Building '_ openssl' extension
- Creatingbuild/temp. linux-x86_64-2.7/build
- Creatingbuild/temp. linux-x86_64-2.7/build/temp. linux-x86_64-2.7
- 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-cbuild/temp. linux-x86_64-2.7/_ openssl. c-obuild/temp. linux-x86_64-2.7/build/temp. linux-x86_64-2.7/_ openssl. o
- Build/temp. linux-x86_64-2.7/_ openssl. c: 434: 30: fatalerror: openssl/opensslv. h: Nosuchfileordirectory
- # Include <openssl/opensslv. h>
- ^
- Compilationterminated.
- Error: command 'gcc 'failedwithexitstatus1
- ----------------------------------------
- Command "/usr/bin/python2-u-c" importsetuptools, tokenize ;__ file __= '/tmp/pip-build-hRMlG0/cryptography/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-ReCoWo-record/install-record.txt -- single-version-externally-managed -- compile" failedwitherrorcode1in/tmp/pip-build-hRMlG0/cryptography/
- [Root @ AY131203102210033c39Z ~] # Yuminstallopensslbuild/temp. linux-x86_64-2.7/_ openssl. c: 434: 30: fatalerror: openssl/opensslv. h: Nosuchfileordirectory
- ^ C
- Exitingonusercancel.
The openssl. c file fails to be installed, and the corresponding file does not appear to be found.
2. Problem Analysis
Check whether openssl is installed:
> Yum info openssl
[Html] view plaincopy
- Loadedplugins: fastestmirror
- Loadingtransferspeedsfromcachedhostfile
- * Base: mirrors.aliyun.com
- * Epel: mirrors.aliyun.com
- * Extras: mirrors.aliyun.com
- * Updates: mirrors.aliyun.com
- InstalledPackages
- Name: openssl
- Arch: x86_64
- Epoch: 1
- Version: 1.0.1e
- Release: 60. el7_3.1
- Size: 1.5 M
- Repo: installed
- Summary: UtilitiesfromthegeneralpurposecryptographylibrarywithTLSimplementation
- URL: http://www.openssl.org/
- License: OpenSSL
- Description: TheOpenSSLtoolkitprovidessupportforsecurecommunicationsbetween
- : Machines. OpenSSLincludesacertificatemanagementtoolandshared
- : Librarieswhichprovidevariouscryptographicalgorithmsand
- : Protocols.
Based on the information, we can know that openssl is an installed file. Why is it still missing the openssl. c file?
After some thought, we suddenly found a basic rule that openssl has installed a binary executable program, and here the installation of scrapy requires the openssl source file program, such as openssl. h. Therefore, we need to install the openssh. h development version, which contains the relevant installation source code file.
3. Problem Solving
After confirming the problem, install the openssl-devel installation package:
> Yum install openssl-devel
After the installation is complete, reinstall scrapy to successfully install scrapy.
4. Summary
By extension, there are similar problems in Linux systems. When installing a specific installation package, it depends on some third-party development kits, and some files cannot be found, generally, the development version of the dependent package needs to be installed. This rule should be generic.