当前位置: 移动技术网 > 网络运营>服务器>Linux > Linux中openssl/opensslv.h找不到问题的解决方法

Linux中openssl/opensslv.h找不到问题的解决方法

2019年04月22日  | 移动技术网网络运营  | 我要评论

前言

众所周知scrapy是python中鼎鼎大名的爬虫框架,在安装scrapy过程中碰到了openssl某个文件找不到的问题,并进行了分析,记录之。

一、 scrapy以及安装过程

scrapy是python中鼎鼎大名的爬虫框架,笔者在centos 7系统之上进行安装,发现了如下问题:

   >> pip install scrapy

由于安装过程中的过程信息比较多,这里只列出了其中的关键片段信息:

 running egg_info 
 writing requirements to src/cryptography.egg-info/requires.txt 
 writing src/cryptography.egg-info/pkg-info 
 writing top-level names to src/cryptography.egg-info/top_level.txt 
 writing dependency_links to src/cryptography.egg-info/dependency_links.txt 
 writing entry points to src/cryptography.egg-info/entry_points.txt 
 reading manifest file 'src/cryptography.egg-info/sources.txt' 
 reading manifest template 'manifest.in' 
 no previously-included directories found matching 'docs/_build' 
 warning: no previously-included files matching '*' found under directory 'vectors' 
 writing manifest file 'src/cryptography.egg-info/sources.txt' 
 running build_ext 
 generating cffi module 'build/temp.linux-x86_64-2.7/_padding.c' 
 creating build/temp.linux-x86_64-2.7 
 generating cffi module 'build/temp.linux-x86_64-2.7/_constant_time.c' 
 generating cffi module 'build/temp.linux-x86_64-2.7/_openssl.c' 
 building '_openssl' extension 
 creating build/temp.linux-x86_64-2.7/build 
 creating build/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 -c build/temp.linux-x86_64-2.7/_openssl.c -o build/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: fatal error: openssl/opensslv.h: no such file or directory 
 #include <openssl/opensslv.h> 
     ^ 
 compilation terminated. 
 error: command 'gcc' failed with exit status 1 
 
 ---------------------------------------- 
command "/usr/bin/python2 -u -c "import setuptools, 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" failed with error code 1 in /tmp/pip-build-hrmlg0/cryptography/ 
[root@ay131203102210033c39z ~]# yum install openssl build/temp.linux-x86_64-2.7/_openssl.c:434:30: fatal error: openssl/opensslv.h: no such file or directory 
^c 
 
exiting on user cancel. 

由于确实openssl.c文件而安装失败了,貌似没有找到对应的文件

二、问题分析

首先怀疑openssl没有安装,故先进行openssl的检查:

  >> yum info openssl 

loaded plugins: fastestmirror 
loading mirror speeds from cached hostfile 
 * base: mirrors.aliyun.com 
 * epel: mirrors.aliyun.com 
 * extras: mirrors.aliyun.com 
 * updates: mirrors.aliyun.com 
installed packages 
name : openssl 
arch : x86_64 
epoch : 1 
version : 1.0.1e 
release : 60.el7_3.1 
size : 1.5 m 
repo : installed 
summary : utilities from the general purpose cryptography library with tls implementation 
url  : http://www.openssl.org/ 
license : openssl 
description : the openssl toolkit provides support for secure communications between 
  : machines. openssl includes a certificate management tool and shared 
  : libraries which provide various cryptographic algorithms and 
  : protocols. 

基于其中的信息可以得知,openssl是一家安装过了,怎么还是会缺少openssl.c的文件呢?

经过一番思考,豁然发现一个基本规则, openssl已经安装二进制的可执行程序,而这里的安装scrapy则需要的是openssl的源文件程序,比如openssl.h。故这里需要补充安装的是openssh.h的开发版,其中包含相关的安装源代码文件。

三、问题的解决

在确认了问题之后,接下来就是安装openssl-devel的安装包了:

  >> yum install openssl-devel

在安装完成之后,重新安装scrapy,就可以顺利安装成功了

总结

推而广之,在linux系统中都存在类似的问题,在安装特定安装包的过程中,其依赖某些第三方开发包,会曝出某些文件找不到的错误,一般情况下是需要安装依赖包的开发版本的。 这个规则应该是通用的。

好了,以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对移动技术网的支持。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网