安装scrapy之后,开始第一步创建scrapy的工程,之后提示一个userwarning:提示我service_identity没有安装,我通过pip install service_identity安装之后,重新创建一个scrapy的爬虫工程有提示以下的错误。
Traceback (most recent call last): File "/usr/local/bin/scrapy", line 4, in execute() File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 122, in execute cmds = get_commands_dict(settings, inproject) File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 46, in get_commands_dict cmds = _get_commands_from_module('scrapy.commands', inproject) File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 29, in _get_commands_from_module for cmd in _iter_command_classes(module): File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 20, in _iter_command_classes for module in walk_modules(module_name): File "/usr/local/lib/python2.7/dist-packages/scrapy/utils/misc.py", line 68, in walk_modules submod = import_module(fullpath) File "/usr/lib/python2.7/importlib/__init.py", line 37, in import_module import(name) File "/usr/local/lib/python2.7/dist-packages/scrapy/commands/bench.py", line 3, in from scrapy.tests.mockserver import MockServer File "/usr/local/lib/python2.7/dist-packages/scrapy/tests/mockserver.py", line 6, in from twisted.internet import reactor, defer, ssl File "/usr/local/lib/python2.7/dist-packages/twisted/internet/ssl.py", line 223, in from twisted.internet.sslverify import ( File "/usr/local/lib/python2.7/dist-packages/twisted/internet/sslverify.py", line 184, in verifyHostname, VerificationError = _selectVerifyImplementation() File "/usr/local/lib/python2.7/dist-packages/twisted/internet/_sslverify.py", line 159, in _selectVerifyImplementation from service_identity import VerificationError File "/usr/local/lib/python2.7/dist-packages/service_identity/__init.py", line 11, in from . import pyopenssl File "/usr/local/lib/python2.7/dist-packages/service_identity/pyopenssl.py", line 12, in from pyasn1_modules.rfc2459 import GeneralNames File "/usr/local/lib/python2.7/dist-packages/pyasn1_modules/rfc2459.py", line 72, in class AttributeValue(univ.Any): pass AttributeError: 'module' object has no attribute 'Any'
原因就是PyASN1这个包的版本过低导致的,通过easy_install重新安装一下这个包就可以了。我安装的PyASN1包是0.1.7,而service_identity包是14.0.0.
service_identity 模块 AttributeError: 'module' object has no attribute 'Any'
原文地址:http://blog.csdn.net/djd1234567/article/details/45506249