安装scrapy时出现“AttributeError: module ‘OpenSSL.SSL‘ has no attribute ‘TLS_METHOD‘”报错的解决方法

一、问题重现

pip安装scrapy 2.5.1:

pip install scrapy==2.5.1

输入命令scrapy version --verbose后报如下错误:

AttributeError: module 'OpenSSL.SSL' has no attribute 'TLS_METHOD'

二、解决方法

1、pip卸载cryptography:

pip uninstall cryptography

重新安装cryptography 36.0.2:

pip install cryptography==36.0.2

2、pip卸载pyOpenSSL:

pip uninstall pyOpenSSL

重新安装pyOpenSSL 22.0.0:

pip install pyOpenSSL==22.0.0

三、测试

输入命令scrapy version --verbose

C:\Users\Xxx>scrapy version --verbose
Scrapy       : 2.5.1
lxml         : 4.6.1.0
libxml2      : 2.9.10
cssselect    : 1.1.0
parsel       : 1.6.0
w3lib        : 1.22.0
Twisted      : 22.8.0
Python       : 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
pyOpenSSL    : 22.0.0 (OpenSSL 1.1.1n  15 Mar 2022)
cryptography : 36.0.2
Platform     : Windows-10-10.0.19041-SP0

Scrapy安装成功!

你可能感兴趣的:(Python爬虫,scrapy,ssl,python)