解決centos中的 openssl/opensslv.h找不到的相關問題

來源:互聯網
上載者:User

解決centos中的 openssl/opensslv.h找不到的相關問題

引言: scrapy是Python中鼎鼎大名的爬蟲架構,在安裝scrapy過程中碰到了openssl某個檔案找不到的問題,並進行了分析,記錄之。

1. scrapy以及安裝過程

Scrapy是Python中鼎鼎大名的爬蟲架構,筆者在Centos 7系統之上進行安裝,發現了如下問題:

>> pip install scrapy

由於安裝過程中的過程資訊比較多,這裡只列出了其中的關鍵片段資訊:

[html]view plaincopy
  1. runningegg_info
  2. writingrequirementstosrc/cryptography.egg-info/requires.txt
  3. writingsrc/cryptography.egg-info/PKG-INFO
  4. writingtop-levelnamestosrc/cryptography.egg-info/top_level.txt
  5. writingdependency_linkstosrc/cryptography.egg-info/dependency_links.txt
  6. writingentrypointstosrc/cryptography.egg-info/entry_points.txt
  7. readingmanifestfile'src/cryptography.egg-info/SOURCES.txt'
  8. readingmanifesttemplate'MANIFEST.in'
  9. nopreviously-includeddirectoriesfoundmatching'docs/_build'
  10. warning:nopreviously-includedfilesmatching'*'foundunderdirectory'vectors'
  11. writingmanifestfile'src/cryptography.egg-info/SOURCES.txt'
  12. runningbuild_ext
  13. generatingcffimodule'build/temp.linux-x86_64-2.7/_padding.c'
  14. creatingbuild/temp.linux-x86_64-2.7
  15. generatingcffimodule'build/temp.linux-x86_64-2.7/_constant_time.c'
  16. generatingcffimodule'build/temp.linux-x86_64-2.7/_openssl.c'
  17. building'_openssl'extension
  18. creatingbuild/temp.linux-x86_64-2.7/build
  19. creatingbuild/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7
  20. 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
  21. build/temp.linux-x86_64-2.7/_openssl.c:434:30:fatalerror:openssl/opensslv.h:Nosuchfileordirectory
  22. #include<openssl/opensslv.h>
  23. ^
  24. compilationterminated.
  25. error:command'gcc'failedwithexitstatus1
  26. ----------------------------------------
  27. 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/
  28. [root@AY131203102210033c39Z~]#yuminstallopensslbuild/temp.linux-x86_64-2.7/_openssl.c:434:30:fatalerror:openssl/opensslv.h:Nosuchfileordirectory
  29. ^C
  30. Exitingonusercancel.
由於確實openssl.c檔案而安裝失敗了,貌似沒有找到對應的檔案

2. 問題分析

首先懷疑openssl沒有安裝,故先進行openssl的檢查:

>> yum info openssl

[html]view plaincopy
  1. Loadedplugins:fastestmirror
  2. Loadingmirrorspeedsfromcachedhostfile
  3. *base:mirrors.aliyun.com
  4. *epel:mirrors.aliyun.com
  5. *extras:mirrors.aliyun.com
  6. *updates:mirrors.aliyun.com
  7. InstalledPackages
  8. Name:openssl
  9. Arch:x86_64
  10. Epoch:1
  11. Version:1.0.1e
  12. Release:60.el7_3.1
  13. Size:1.5M
  14. Repo:installed
  15. Summary:UtilitiesfromthegeneralpurposecryptographylibrarywithTLSimplementation
  16. URL:http://www.openssl.org/
  17. License:OpenSSL
  18. Description:TheOpenSSLtoolkitprovidessupportforsecurecommunicationsbetween
  19. :machines.OpenSSLincludesacertificatemanagementtoolandshared
  20. :librarieswhichprovidevariouscryptographicalgorithmsand
  21. :protocols.
基於其中的資訊可以得知,openssl是一家安裝過了,怎麼還是會缺少openssl.c的檔案呢?

經過一番思考,豁然發現一個基本規則, openssl已經安裝二進位的可執行程式,而這裡的安裝scrapy則需要的是openssl的源檔案程式,比如openssl.h。故這裡需要匯集安裝的是openssh.h的開發版,其中包含相關的安裝原始碼檔案。

3. 問題的解決

在確認了問題之後,接下來就是安裝openssl-devel的安裝包了:

>> yum install openssl-devel

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

4. 總結

推而廣之,在Linux系統中都存在類似的問題,在安裝特定安裝包的過程中,其依賴某些第三方開發包,會曝出某些檔案找不到的錯誤,一般情況下是需要安裝依賴包的開發版本的。 這個規則應該是通用的。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.