2017-05-30 108 views
0

我在virtualenv裏安裝了Ubuntu 12.04,python 3.5.2上的scrapy。我在安裝scrapy時遇到了很多麻煩,但我終於安裝了所有要求。我必須手動安裝twis​​ted才能完成安裝,但我已安裝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 
+0

在你的virtualenv中'哪個scrapy'指向'bin/scrapy'? –

+0

除了'pip install scrapy'應該安裝的'bin/scrapy'之外,你可以嘗試'python -m scrapy.cmdline'作爲'scrapy'的別名,例如'python -m scrapy.cmdline version -v' –

+0

如果可能,請考慮從Ubuntu 12.04開始 - 從2017年4月上個月開始,它不再收到安全更新。 [Ubuntu Release End-Of-Life](https://www.ubuntu.com/info/release-end-of-life) – chucksmash

回答

0

您將需要爲涉及的所有擴展模塊安裝構建依賴項。那將至少包括GCC,libffi-dev的,和中的libssl-dev的(但可能更多):

sudo apt-get install gcc libffi-dev libssl-dev 

在安裝編譯依賴,你應該安裝的Python軟件的所有到的virtualenv 。

virtualenv --python=python3.5 scrapy-environment 
. scrapy-environment/bin/activate 
pip install scrapy 
scrapy ... 

如果您遇到一些錯誤,請更新您的問題以包含該錯誤的詳細信息。

+0

感謝您的回答。我結束了安裝miniconda並通過conda僞造安裝scrapy,這完美地工作。如果我需要回去安裝沒有conda,我將不得不嘗試這種方法 – jDull