溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Linux中openssl/opensslv.h找不到問題的解決方法

發(fā)布時(shí)間:2020-09-05 02:49:21 來源:腳本之家 閱讀:405 作者:bladestone 欄目:服務(wù)器

前言

眾所周知scrapy是Python中鼎鼎大名的爬蟲框架,在安裝scrapy過程中碰到了openssl某個(gè)文件找不到的問題,并進(jìn)行了分析,記錄之。

一、 scrapy以及安裝過程

Scrapy是python中鼎鼎大名的爬蟲框架,筆者在Centos 7系統(tǒng)之上進(jìn)行安裝,發(fā)現(xiàn)了如下問題:

   >> pip install scrapy

由于安裝過程中的過程信息比較多,這里只列出了其中的關(guān)鍵片段信息:

 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. 

由于確實(shí)openssl.c文件而安裝失敗了,貌似沒有找到對(duì)應(yīng)的文件

二、問題分析

首先懷疑openssl沒有安裝,故先進(jìn)行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是一家安裝過了,怎么還是會(huì)缺少openssl.c的文件呢?

經(jīng)過一番思考,豁然發(fā)現(xiàn)一個(gè)基本規(guī)則, openssl已經(jīng)安裝二進(jìn)制的可執(zhí)行程序,而這里的安裝scrapy則需要的是openssl的源文件程序,比如openssl.h。故這里需要補(bǔ)充安裝的是openssh.h的開發(fā)版,其中包含相關(guān)的安裝源代碼文件。

三、問題的解決

在確認(rèn)了問題之后,接下來就是安裝openssl-devel的安裝包了:

  >> yum install openssl-devel

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

總結(jié)

推而廣之,在Linux系統(tǒng)中都存在類似的問題,在安裝特定安裝包的過程中,其依賴某些第三方開發(fā)包,會(huì)曝出某些文件找不到的錯(cuò)誤,一般情況下是需要安裝依賴包的開發(fā)版本的。 這個(gè)規(guī)則應(yīng)該是通用的。

好了,以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對(duì)億速云的支持。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI