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