我在virtualenv裏安裝了Ubuntu 12.04,python 3.5.2上的scrapy。我在安裝scrapy時遇到了很多麻煩,但我終於安裝了所有要求。我必須手動安裝twisted才能完成安裝,但我已安裝Twisted 17.0。但是,當我嘗試運行教程時,出現以下錯誤:Scrapy「The Twisted> = 13.1.0'發行版沒有被發現,Scrapy需要」
Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2927, in <module>
@_call_aside
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2913, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2940, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 635, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 943, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py", line 829, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'Twisted>=13.1.0' distribution was not found and is required by Scrapy
Twisted 17.0已安裝,似乎正在工作。當我導入scrapy並在Python中扭曲時,我沒有得到任何錯誤(它找到了模塊),但作爲命令,scrapy不起作用。
Python 3.5.2 (default, Nov 2 2016, 11:15:44)
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import scrapy
>>> import twisted
在你的virtualenv中'哪個scrapy'指向'bin/scrapy'? –
除了'pip install scrapy'應該安裝的'bin/scrapy'之外,你可以嘗試'python -m scrapy.cmdline'作爲'scrapy'的別名,例如'python -m scrapy.cmdline version -v' –
如果可能,請考慮從Ubuntu 12.04開始 - 從2017年4月上個月開始,它不再收到安全更新。 [Ubuntu Release End-Of-Life](https://www.ubuntu.com/info/release-end-of-life) – chucksmash