2017-02-22 9 views
0

我haved上Python 3.5.2安裝scrapy,但是當我在命令行exeute scrapy -v,它發生:導入錯誤:沒有名爲模塊「twisted.persisted」

>> 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,以確保無論是porperly安裝:

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' 

我很困惑,我只想運行一個spaider,所以幫助我!

+0

您也可以通過輸入'pip show 來檢查包版本和其他包信息' – Granitosaurus

回答

0

你的扭曲的版本已經過時,如果你看一下requirements-py3.txtfile

Twisted >= 15.5.0
lxml>=3.2.4
pyOpenSSL>=0.13.1
cssselect>=0.9
queuelib>=1.1.1
w3lib>=1.17.0
service_identity

如果你的是,15.2。
目前最新的版本是17.1.0,並且沒有運行它的缺點;請嘗試:

pip3 install twisted --upgrade 
相關問題