服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Linux - Linux中openssl/opensslv.h找不到问题的解决方法

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

2022-01-25 17:05bladestone Linux

最近在安装scrapy过程中碰到了openssl某个文件找不到的问题,通过查找相关的资料进行了解决,下面这篇文章主要给大家分享了关于Linux中openssl/opensslv.h找不到问题的解决方法,需要的朋友可以参考借鉴,下面来一起看看吧。

前言

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

一、 scrapy以及安装过程

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

   >> pip install scrapy

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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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系统中都存在类似的问题,在安装特定安装包的过程中,其依赖某些第三方开发包,会曝出某些文件找不到的错误,一般情况下是需要安装依赖包的开发版本的。 这个规则应该是通用的。

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

原文链接:http://blog.csdn.net/blueheart20/article/details/65653670

延伸 · 阅读

精彩推荐
  • LinuxLinux lnmp下无法使用mail发邮件的两种解决方法

    Linux lnmp下无法使用mail发邮件的两种解决方法

    在配置了lnmp环境后,出现了mail函数不能发送邮件的问题,其实有两种方法,一是使用sendmail组件,而是使用postfix。下面为大家一一介绍下 ...

    Linux之家4042019-09-17
  • Linux详解Linux系统下PXE服务器的部署过程

    详解Linux系统下PXE服务器的部署过程

    这篇文章主要介绍了Linux系统下PXE服务器的部署过程,包括对PXE的API架构作了一个基本的简介,需要的朋友可以参考下...

    运维之道9812019-07-04
  • Linux确保Linux系统安全的前提条件 漏洞防护

    确保Linux系统安全的前提条件 漏洞防护

    Linux 作为开放式的操作系统受到很多程序员的喜爱,很多高级程序员都喜欢编写Linux操作系统的相关软件。这使得Linux操作系统有着丰富的软件支持,还有无...

    Linux之家2642020-04-11
  • LinuxLinux常用的日志文件和常用命令

    Linux常用的日志文件和常用命令

    成功地管理任何系统的关键之一,是要知道系统中正在发生什么事。 Linux 中提供了异常日志,并且日志的细节是可配置的。Linux 日志都以明文形式存储,所...

    Linux教程网2632020-04-18
  • LinuxLinux中环境变量配置的步骤详解

    Linux中环境变量配置的步骤详解

    Linux中环境变量包括系统级和用户级,系统级的环境变量是每个登录到系统的用户都要读取的系统变量,而用户级的环境变量则是该用户使用系统时加载的...

    Myths7882022-02-10
  • LinuxLinux上设置用户通过SFTP访问目录的权限的方法

    Linux上设置用户通过SFTP访问目录的权限的方法

    这篇文章主要介绍了Linux上设置用户通过SFTP访问目录的权限的方法,SFTP可以理解为使用SSH协议进行FTP传输的协议,因而同时要对OpenSSH进行相关设置,需要的朋...

    OSChina10022019-06-19
  • Linuxlinux中rmdir命令使用详解(删除空目录)

    linux中rmdir命令使用详解(删除空目录)

    今天学习一下linux中命令: rmdir命令。rmdir是常用的命令,该命令的功能是删除空目录,一个目录被删除之前必须是空的 ...

    linux命令大全5372019-11-19
  • Linux手把手教您在 Linux 上使用 GPG 加解密文件

    手把手教您在 Linux 上使用 GPG 加解密文件

    在本教程中,我将告诉你如何用 GPG 加密和解密文件。这是一个简单的教程,你可以在你的 Linux 系统上尝试所有的练习。这将帮助你练习 GPG 命令,并在你...

    Linux中国6962021-12-15