Ubuntu 下安装 Pyspider

官网上说:

$ sudo pip install pyspider

安装貌似成功, 检测时, 然而, 报错了:

$ pyspider all
Traceback (most recent call last):
  File "/usr/local/bin/pyspider", line 9, in 
    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 文件夹. 执行:

$ 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, 再一个潇洒回车, 啊... 画面太美,不敢直视.

撸完这一切, 我默默的竖起了中指....

你可能感兴趣的:(Ubuntu 下安装 Pyspider)