2014-08-29 106 views
12

我試圖安裝Scrapy easy_install -U Scrapy,但它試圖安裝時發生奇怪的錯誤「無法打開包含文件」。有人知道發生了什麼嗎?這裏是我完整的回溯:Scrapy安裝失敗,錯誤'無法打開包括:'openssl/aes.h'

C:\Users\Mubashar Kamran>easy_install -U Scrapy 
Searching for Scrapy 
Reading https://pypi.python.org/simple/Scrapy/ 
Best match: scrapy 0.24.4 
Processing scrapy-0.24.4-py2.7.egg 
scrapy 0.24.4 is already the active version in easy-install.pth 
Installing scrapy-script.py script to C:\Python27\Scripts 
Installing scrapy.exe script to C:\Python27\Scripts 
Installing scrapy.exe.manifest script to C:\Python27\Scripts 

Using c:\python27\lib\site-packages\scrapy-0.24.4-py2.7.egg 
Processing dependencies for Scrapy 
Searching for cryptography>=0.2.1 
Reading https://pypi.python.org/simple/cryptography/ 
Best match: cryptography 0.5.4 
Downloading https://pypi.python.org/packages/source/c/cryptography/cryptography- 
0.5.4.tar.gz#md5=4fd1f10e9f99009a44667fabe7980aec 
Processing cryptography-0.5.4.tar.gz 
Writing c:\users\mubash~1\appdata\local\temp\easy_install-jjms3i\cryptography-0. 
5.4\setup.cfg 
Running cryptography-0.5.4\setup.py -q bdist_egg --dist-dir c:\users\mubash~1\ap 
pdata\local\temp\easy_install-jjms3i\cryptography-0.5.4\egg-dist-tmp-ry6bwd 
C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 
'setup_requires' 
    warnings.warn(msg) 
_Cryptography_cffi_684bb40axf342507b.c 
    Creating library c:\users\mubash~1\appdata\local\temp\easy_install-jjms3i\cry 
ptography-0.5.4\cryptography\hazmat\primitives\__pycache__\Release\cryptography\ 
hazmat\primitives\__pycache__\_Cryptography_cffi_684bb40axf342507b.lib and objec 
t c:\users\mubash~1\appdata\local\temp\easy_install-jjms3i\cryptography-0.5.4\cr 
yptography\hazmat\primitives\__pycache__\Release\cryptography\hazmat\primitives\ 
__pycache__\_Cryptography_cffi_684bb40axf342507b.exp 
_Cryptography_cffi_8f86901cxc1767c5a.c 
    Creating library c:\users\mubash~1\appdata\local\temp\easy_install-jjms3i\cry 
ptography-0.5.4\cryptography\hazmat\primitives\__pycache__\Release\cryptography\ 
hazmat\primitives\__pycache__\_Cryptography_cffi_8f86901cxc1767c5a.lib and objec 
t c:\users\mubash~1\appdata\local\temp\easy_install-jjms3i\cryptography-0.5.4\cr 
yptography\hazmat\primitives\__pycache__\Release\cryptography\hazmat\primitives\ 
__pycache__\_Cryptography_cffi_8f86901cxc1767c5a.exp 
_Cryptography_cffi_4ed9e37dx4000d087.c 
cryptography\hazmat\bindings\__pycache__\_Cryptography_cffi_4ed9e37dx4000d087.c(
194) : fatal error C1083: Cannot open include file: 'openssl/aes.h': No such fil 
e or directory 
error: c:\users\mubash~1\appdata\local\temp\easy_install-jjms3i\cryptography-0.5 
.4\cryptography\hazmat\primitives\__pycache__\_Cryptography_cffi_684bb40axf34250 
7b.pyd: Access is denied 

回答

29

我得到同樣的錯誤安裝不同的python應用程序。我缺少的OpenSSL dev軟件包,以解決:

sudo apt-get install libssl-dev 
+0

這個答案適合我。 – 2015-05-08 18:40:01

10

在OSX

brew install openssl,然後可能brew link openssl --force如果你被告知所有未創建的鏈接。

安裝Scrapy使用以下命令

env CRYPTOGRAPHY_OSX_NO_LINK_FLAGS=1 LDFLAGS="$(brew --prefix openssl)/lib/libssl.a $(brew --prefix openssl)/lib/libcrypto.a" CFLAGS="-I$(brew --prefix openssl)/include" pip install scrapy

你可以,如果你願意的話,替換爲openssllibressl

+0

'brew link openssl --force'在'/ usr/local/include'中添加了適當的符號鏈接,它爲我解決了這個問題。 – 2015-10-14 23:08:22

+0

'brew links openssl --force'也適用於我。之後,'pip install scrapy'運行完成。 – 2016-06-05 23:15:19

2

這足以將OpenSSL安裝

brew install openssl 

和〜/ .bash_profile中導出

export LDFLAGS=-L/usr/local/opt/openssl/lib 
export CPPFLAGS=-I/usr/local/opt/openssl/include 

。 儘量避免與--force參數鏈接,因爲它可能導致與系統庫的衝突。

+0

授予問題的提問者可以說是windows,謝謝Pavel作爲OSX用戶,這是我需要的微調。 – 2016-07-01 22:51:28

相關問題