ImportError:无法导入名称解包

时间:2015-05-06 12:59:58

标签: python scrapy importerror

我已经使用pip install scrapy安装了scrapy。但是在python shell中我得到了一个ImportError:

>>> from scrapy.spider import Spider
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/scrapy/__init__.py", line 56, in <module>
    from scrapy.spider import Spider
  File "/usr/local/lib/python2.7/dist-packages/scrapy/spider.py", line 7, in <module>
    from scrapy.http import Request
  File "/usr/local/lib/python2.7/dist-packages/scrapy/http/__init__.py", line 10, in <module>
    from scrapy.http.request import Request
  File "/usr/local/lib/python2.7/dist-packages/scrapy/http/request/__init__.py", line 15, in <module>
    from scrapy.utils.url import escape_ajax
  File "/usr/local/lib/python2.7/dist-packages/scrapy/utils/url.py", line 10, in <module>
    import urllib
  File "urllib.py", line 1, in <module>
    import urllib2, json
  File "/usr/lib/python2.7/urllib2.py", line 112, in <module>
    from urllib import (unwrap, unquote, splittype, splithost, quote,
ImportError: cannot import name unwrap

同样对于scrapy shell,我也遇到了同样的错误。所以我用autoremove卸载scrapy并再次安装但没有变化。我错过了什么吗?

1 个答案:

答案 0 :(得分:7)

看起来你已经定义了一个名为urllib.py的模块,阴影内置urllib模块。删除/重命名文件。