python版本为3.7
因为用anaconda安装scrapy非常方便,会自动下载所依赖的包,
所以就使用anaconda安装scrapy, 非常舒服,安装很成功
conda install scrapy
问题出现
当使用scrapy时出现报错, 这里我是创建新项目,发现报错
报错信息如下:
Traceback (most recent call last):
File "G:anacondaScriptsscrapy-script.py", line 10, in <module>
sys.exit(execute())
File "G:anacondalibsite-packagesscrapycmdline.py", line 149, in execute
cmd.crawler_process = CrawlerProcess(settings)
File "G:anacondalibsite-packagesscrapycrawler.py", line 252, in __init__
log_scrapy_info(self.settings)
File "G:anacondalibsite-packagesscrapyutilslog.py", line 149, in log_scrapy_info
for name, version in scrapy_components_versions()
File "G:anacondalibsite-packagesscrapyutilsversions.py", line 35, in scrapy_components_versions
("pyOpenSSL", _get_openssl_version()),
File "G:anacondalibsite-packagesscrapyutilsversions.py", line 43, in _get_openssl_version
import OpenSSL
File "G:anacondalibsite-packagesOpenSSL\__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "G:anacondalibsite-packagesOpenSSLcrypto.py", line 16, in <module>
from OpenSSL._util import (
File "G:anacondalibsite-packagesOpenSSL\_util.py", line 6, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "G:anacondalibsite-packagescryptographyhazmatindingsopensslinding.py", line 13, in <module>
from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: DLL load failed: 操作系统无法运行 %1。
其中最关键的报错应该是最后一个
File “G:anacondalibsite-packagescryptographyhazmatindingsopensslinding.py”, line 13, in
from cryptography.hazmat.bindings._openssl import ffi, lib
解决方法
把你安装路径下的libeay32.dll和ssleay32.dll,放到C:windowssystem32
比如我的安装路径是
G:anacondapkgsopenssl-1.0.2o-h2c51139_0Libraryin
如果找不到 你可以使用everything这个软件(比系统自带的搜索好用多了,而且小)搜索libeay32.dll,找到相应路径
然后把文件复制到
C:WindowsSystem32
路径下, 问题解决!
参考博客:https://www.jianshu.com/p/7001c8a9e1fa