我已经使用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并再次安装但没有变化。我错过了什么吗?
答案 0 :(得分:7)
看起来你已经定义了一个名为urllib.py
的模块,阴影内置urllib
模块。删除/重命名文件。