ImportError: cannot import name unwrap

匿名 (未验证) 提交于 2019-12-03 09:14:57

问题:

I have installed scrapy with pip install scrapy. But in python shell I am getting an 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 

Also for scrapy shell, I am getting the same error. So I uninstalled scrapy with autoremove and installed it again but no change. Am I missing out on something?

回答1:

It looks like that you've defined a module called urllib.py which shadows built-in urllib module. Remove/rename the file.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!