官網(wǎng)上說:
$ sudo pip install pyspider
安裝貌似成功, 檢測時, 然而, 報錯了:
$ pyspider all
Traceback (most recent call last):
File "/usr/local/bin/pyspider", line 9, in <module>
load_entry_point('pyspider==0.3.10-dev', 'console_scripts', 'pyspider')()
File "/usr/local/lib/python2.7/dist-packages/pyspider-0.3.10_dev-py2.7.egg/pyspider/run.py", line 754, in main
cli()
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1043, in invoke
return Command.invoke(self, ctx)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pyspider-0.3.10_dev-py2.7.egg/pyspider/run.py", line 97, in cli
logging.config.fileConfig(kwargs['logging_config'])
File "/usr/lib/python2.7/logging/config.py", line 77, in fileConfig
formatters = _create_formatters(cp)
File "/usr/lib/python2.7/logging/config.py", line 135, in _create_formatters
f = c(fs, dfs)
File "/usr/local/lib/python2.7/dist-packages/pyspider-0.3.10_dev-py2.7.egg/pyspider/libs/log.py", line 22, in __init__
fmt = _LogFormatter.DEFAULT_FORMAT
AttributeError: type object 'LogFormatter' has no attribute 'DEFAULT_FORMAT'
一查, 原來是這個包 tornado
版本太低了, 低到那時候:
type object 'LogFormatter' has no attribute 'DEFAULT_FORMAT'
跑去最新版的 tornado
一看, 果然有此屬性.
解決方法: 升級 tornado
.
$ sudo pip install -U tornado
然而, 不行...
只能使出簡單粗暴的方式了, 就是先編譯安裝一個最新的 tornado
, 然后, 刪除掉原先那個, 再把新的拷貝一份過去.具體操作如下:
最先想用 pip
安裝, 然而敗了.
$ sudo pip install tornado
所以, 只好用源碼編譯安裝. 首先,先去 Github 下載一個 tornado
. 解壓并進去 tornado
文件夾. 執(zhí)行:
$ python setup.py build
$ sudo python setup.py install
$ sudo rm -R /usr/lib/python2.7/dist-packages/tornado
$ sudo copy -r /usr/local/lib/python2.7/dist-packages/tornado-4.5.2-py2.7-linux-x86_64.egg/tornado /usr/lib/python2.7/dist-packages/
最后, 測試一波.
$ pyspider all
打開瀏覽器,輸入: localhost:5000, 再一個瀟灑回車, 啊... 畫面太美,不敢直視.
擼完這一切, 我默默的豎起了中指....