ImportError:没有名为' twisted.persisted'

时间:2017-02-22 06:27:17

标签: scrapy twisted

我已经在Python 3.5.2上安装了scrapy,但是当我在命令行上执行scrapy -v时,它会发生:

>> scrapy -v
Traceback (most recent call last):
  File "/usr/bin/scrapy", line 7, in <module>
    from scrapy.cmdline import execute
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/scrapy/__init__.py", line 27, in <module>
    from . import _monkeypatches
  File "/usr/local/python3.5.2/lib/python3.5/site-packages/scrapy/_monkeypatches.py", line 20, in <module>
    import twisted.persisted.styles  # NOQA
ImportError: No module named 'twisted.persisted'

所以我输入ipython3以确保它是否正常安装:

In [2]: import twisted
In [3]: twisted.version
Out[3]: Version('twisted', 15, 2, 1)

但是当我import scrapy时,与命令行相同:

In [4]: import scrapy
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-51c73a18167b> in <module>()
----> 1 import scrapy

/usr/local/python3.5.2/lib/python3.5/site-packages/scrapy/__init__.py in <module>()
     25 
     26 # Apply monkey patches to fix issues in external libraries
---> 27 from . import _monkeypatches
     28 del _monkeypatches
     29 

/usr/local/python3.5.2/lib/python3.5/site-packages/scrapy/_monkeypatches.py in <module>()
     18 # Undo what Twisted's perspective broker adds to pickle register
     19 # to prevent bugs like Twisted#7989 while serializing requests
---> 20 import twisted.persisted.styles  # NOQA
     21 # Remove only entries with twisted serializers for non-twisted types.
     22 for k, v in frozenset(copyreg.dispatch_table.items()):

ImportError: No module named 'twisted.persisted'

我很困惑,我只想跑一个滑雪者,所以帮助我吧!

1 个答案:

答案 0 :(得分:0)

如果您查看requirements-py3.txt file,您的Twisted版本已过时:

  

Twisted&gt; = 15.5.0
  LXML&GT = 3.2.4
  pyOpenSSL&GT = 0.13.1
  cssselect&GT = 0.9
  queuelib&GT = 1.1.1
  w3lib&GT = 1.17.0
  service_identity

你的位置是15.2 目前最新版本为17.1.0并且没有运行它的缺点;尝试:

pip3 install twisted --upgrade