python报错:ImportError: cannot import name 'Interface'

报错结果如下:

Traceback (most recent call last):
  File "main.py", line 16, in 
    from scrapy.selector import Selector
  File "D:\Program\Anaconda3\lib\site-packages\scrapy\__init__.py", line 27, in 
    from . import _monkeypatches
  File "D:\Program\Anaconda3\lib\site-packages\scrapy\_monkeypatches.py", line 20, in 
    import twisted.persisted.styles  # NOQA
  File "D:\Program\Anaconda3\lib\site-packages\twisted\persisted\styles.py", line 24, in 
    from twisted.python import log
  File "D:\Program\Anaconda3\lib\site-packages\twisted\python\log.py", line 17, in 
    from zope.interface import Interface
ImportError: cannot import name 'Interface'

python中也有interface的概念,但是python其本身不提供interface的实现,需要通过第三方扩展库来使用类似interface的功能,一般都是Zope.interface。

可通过pip的方式安装。

python报错:ImportError: cannot import name 'Interface'_第1张图片

如果提示:
python报错:ImportError: cannot import name 'Interface'_第2张图片

应该先执行:pip uninstall zope.interface , 然后再:pip install zope.interface .再运行程序,问题解决。

你可能感兴趣的:(常见错误汇总)