![Windows 上の Python に scrapy をインストールするときの OpenSSL の問題](https://rvso.com/image/1395281/Windows%20%E4%B8%8A%E3%81%AE%20Python%20%E3%81%AB%20scrapy%20%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%99%E3%82%8B%E3%81%A8%E3%81%8D%E3%81%AE%20OpenSSL%20%E3%81%AE%E5%95%8F%E9%A1%8C.png)
私は32ビットインストーラーに切り替えましたPython Scrapy
(スクレイピーを動作させるために64ビットインストーラーをインストールできなかったため)。記載されている手順に従いました。ここ。
easy_install
これは、 を実行したときのログですscrapy
:
Searching for scrapy
Best match: scrapy 0.22.0
Processing scrapy-0.22.0-py2.7.egg
scrapy 0.22.0 is already the active version in easy-install.pth
Installing scrapy script to C:\Python27\Scripts
Installing scrapy.bat script to C:\Python27\Scripts
Using c:\python27\lib\site-packages\scrapy-0.22.0-py2.7.egg
Processing dependencies for scrapy
Searching for cryptography>=0.1
Reading http://pypi.python.org/simple/cryptography/
Best match: cryptography 0.1
Downloading https://pypi.python.org/packages/source/c/cryptography/cryptography-
0.1.tar.gz#md5=bdc1c5fe069deca7467b71a0cc538f17
Processing cryptography-0.1.tar.gz
Running cryptography-0.1\setup.py -q bdist_egg --dist-dir c:\users\faizan\appdat
a\local\temp\easy_install-myikuq\cryptography-0.1\egg-dist-tmp-vfydke
Searching for cffi>=0.6
Reading http://pypi.python.org/simple/cffi/
Best match: cffi 0.8.1
Downloading https://pypi.python.org/packages/source/c/cffi/cffi-0.8.1.tar.gz#md5
=1a877bf113bfe90fdefedbf9e39310d2
Processing cffi-0.8.1.tar.gz
Running cffi-0.8.1\setup.py -q bdist_egg --dist-dir c:\users\faizan\appdata\loca
l\temp\easy_install-myikuq\cryptography-0.1\temp\easy_install-zoguzs\cffi-0.8.1\
egg-dist-tmp-trop2u
_cffi_backend.c
c/_cffi_backend.c(5261) : warning C4146: unary minus operator applied to unsigne
d type, result still unsigned
c/_cffi_backend.c(5262) : warning C4146: unary minus operator applied to unsigne
d type, result still unsigned
c/_cffi_backend.c(5263) : warning C4146: unary minus operator applied to unsigne
d type, result still unsigned
c/_cffi_backend.c(5264) : warning C4146: unary minus operator applied to unsigne
d type, result still unsigned
ffi.c
c/libffi_msvc\ffi.c(122) : warning C4018: '>' : signed/unsigned mismatch
prep_cif.c
types.c
win32.c
Creating library build\temp.win32-2.7\Release\c\_cffi_backend.lib and object
build\temp.win32-2.7\Release\c\_cffi_backend.exp
Installed c:\users\faizan\appdata\local\temp\easy_install-myikuq\cryptography-0.
1\cffi-0.8.1-py2.7-win32.egg
Searching for pycparser
Reading http://pypi.python.org/simple/pycparser/
Best match: pycparser 2.10
Downloading https://pypi.python.org/packages/source/p/pycparser/pycparser-2.10.t
ar.gz#md5=d87aed98c8a9f386aa56d365fe4d515f
Processing pycparser-2.10.tar.gz
Running pycparser-2.10\setup.py -q bdist_egg --dist-dir c:\users\faizan\appdata\
local\temp\easy_install-myikuq\cryptography-0.1\temp\easy_install-ngu9w1\pycpars
er-2.10\egg-dist-tmp-2uhfme
zip_safe flag not set; analyzing archive contents...
Installed c:\users\faizan\appdata\local\temp\easy_install-myikuq\cryptography-0.
1\pycparser-2.10-py2.7.egg
_cffi__xcfd0a060xfba2f231.c
Creating library c:\users\faizan\appdata\local\temp\easy_install-myikuq\crypt
ography-0.1\cryptography\hazmat\primitives\__pycache__\Release\cryptography\hazm
at\primitives\__pycache__\_cffi__xcfd0a060xfba2f231.lib and object c:\users\faiz
an\appdata\local\temp\easy_install-myikuq\cryptography-0.1\cryptography\hazmat\p
rimitives\__pycache__\Release\cryptography\hazmat\primitives\__pycache__\_cffi__
xcfd0a060xfba2f231.exp
_cffi__x5fea2bacx4a8b9ec1.c
cryptography\hazmat\primitives\__pycache__\_cffi__x5fea2bacx4a8b9ec1.c(218) : wa
rning C4244: '=' : conversion from 'unsigned __int64' to 'uint8_t', possible los
s of data
Creating library c:\users\faizan\appdata\local\temp\easy_install-myikuq\crypt
ography-0.1\cryptography\hazmat\primitives\__pycache__\Release\cryptography\hazm
at\primitives\__pycache__\_cffi__x5fea2bacx4a8b9ec1.lib and object c:\users\faiz
an\appdata\local\temp\easy_install-myikuq\cryptography-0.1\cryptography\hazmat\p
rimitives\__pycache__\Release\cryptography\hazmat\primitives\__pycache__\_cffi__
x5fea2bacx4a8b9ec1.exp
_cffi__xd9dc3d0ax8cb54b0a.c
cryptography\hazmat\bindings\__pycache__\_cffi__xd9dc3d0ax8cb54b0a.c(165) : fata
l error C1083: Cannot open include file: 'openssl/asn1.h': No such file or direc
tory
error: c:\users\faizan\appdata\local\temp\easy_install-myikuq\cryptography-0.1\c
ffi-0.8.1-py2.7-win32.egg\_cffi_backend.pyd: Access is denied
私はすべての投稿の回答やチュートリアルを試しました。これを克服するための解決策はありますか?私は64ビットのWindowsマシンを使用しています
答え1
私も Windows XP でまったく同じ問題が発生しています。
openssl/asn1.h にそのようなファイルがない問題を解決するには、LIB
システムINCLUDE
変数を確認してください。
Windows XP では、CMD プロンプト ウィンドウから次のコマンドを使用してこれを実行できます。
SET LIB
SET INCLUDE
これらには、OpenSSL ディレクトリの lib および include フォルダーが含まれている必要があります。私のマシンでは次のようになります。
SET LIB C:\OpenSSL-win32\lib;etc;etc;etc
SET INCLUDE C:\OpenSSL-win32\include;etc;etc
次のようにシステム変数に追加できます。
SET LIB=C:\OPenSSL-win32\lib;%LIB%
残念ながら、これではアクセスが拒否される問題は解決されません。
答え2
後日このスレッドに出会った人がいたら:
Python 2.7 で easy_install を使用して Scrapy をインストールするのに非常に苦労しました。特に暗号化モジュールはインストールできませんでした。
私は以下の情報を使ってpipをインストールしました。https://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows
その後は簡単なpip install scrapy
仕事でビジネスを始めました。