安装scrapy之后,开始第一步创建scrapy的工程,之后提示一个userwarning:提示我service_identity没有安装,我通过pip install service_identity安装之后,重新创建一个scrapy的爬虫工程有提示以下的错误。
Traceback (most recent call last):File "/usr/local/bin/scrapy", line 4, inexecute()File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 122, in executecmds = get_commands_dict(settings, inproject)File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 46, in get_commands_dictcmds = _get_commands_from_module('scrapy.commands', inproject)File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 29, in _get_commands_from_modulefor cmd in _iter_command_classes(module):File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 20, in _iter_command_classesfor module in walk_modules(module_name):File "/usr/local/lib/python2.7/dist-packages/scrapy/utils/misc.py", line 68, in walk_modulessubmod = import_module(fullpath)File "/usr/lib/python2.7/importlib/__init.py", line 37, in import_moduleimport(name)File "/usr/local/lib/python2.7/dist-packages/scrapy/commands/bench.py", line 3, infrom scrapy.tests.mockserver import MockServerFile "/usr/local/lib/python2.7/dist-packages/scrapy/tests/mockserver.py", line 6, infrom twisted.internet import reactor, defer, sslFile "/usr/local/lib/python2.7/dist-packages/twisted/internet/ssl.py", line 223, infrom twisted.internet.sslverify import (File "/usr/local/lib/python2.7/dist-packages/twisted/internet/sslverify.py", line 184, inverifyHostname, VerificationError = _selectVerifyImplementation()File "/usr/local/lib/python2.7/dist-packages/twisted/internet/_sslverify.py", line 159, in _selectVerifyImplementationfrom service_identity import VerificationErrorFile "/usr/local/lib/python2.7/dist-packages/service_identity/__init.py", line 11, infrom . import pyopensslFile "/usr/local/lib/python2.7/dist-packages/service_identity/pyopenssl.py", line 12, infrom pyasn1_modules.rfc2459 import GeneralNamesFile "/usr/local/lib/python2.7/dist-packages/pyasn1_modules/rfc2459.py", line 72, inclass AttributeValue(univ.Any): passAttributeError: 'module' object has no attribute 'Any'
原因就是PyASN1这个包的版本过低导致的,通过easy_install重新安装一下这个包就可以了。我安装的PyASN1包是0.1.7,而service_identity包是14.0.0.