前言
在使用时scrapy框架的shell工具时报错如下信息。
scrapy shell "https://hr.tencent.com/position.php?&start=0"
Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 7, in <module>
from scrapy.cmdline import execute
File "/usr/local/lib/python3.5/dist-packages/scrapy/cmdline.py", line 9, in <module>
from scrapy.crawler import CrawlerProcess
File "/usr/local/lib/python3.5/dist-packages/scrapy/crawler.py", line 7, in <module>
from twisted.internet import reactor, defer
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/reactor.py", line 38, in <module>
from twisted.internet import default
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/default.py", line 56, in <module>
install = _getInstallFunction(platform)
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/default.py", line 44, in _getInstallFunction
from twisted.internet.epollreactor import install
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/epollreactor.py", line 24, in <module>
from twisted.internet import posixbase
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/posixbase.py", line 18, in <module>
from twisted.internet import error, udp, tcp
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/tcp.py", line 31, in <module>
from twisted.internet._newtls import (
File "/usr/local/lib/python3.5/dist-packages/twisted/internet/_newtls.py", line 21, in <module>
from twisted.protocols.tls import TLSMemoryBIOFactory, TLSMemoryBIOProtocol
File "/usr/local/lib/python3.5/dist-packages/twisted/protocols/tls.py", line 41, in <module>
from OpenSSL.SSL import Error, ZeroReturnError, WantReadError
File "/usr/local/lib/python3.5/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/local/lib/python3.5/dist-packages/OpenSSL/SSL.py", line 105, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: module 'lib' has no attribute 'SSL_ST_INIT'
解决方法
根据报错信息我们可以推论是Python3下的OpenSSL模块出错。
把之前的pyopenssl 卸载掉,重新安装:
sudo pip3 uninstall pyopenssl
sudo pip3 install pyopenssl
网友评论