无法在Linux Ubuntu上打开Scrapy

时间:2014-08-09 17:56:40

标签: python ubuntu scrapy

我一直在错误地在我的Linux机器上启动Scrapy。我正在使用Ubuntu 14.0桌面。我已经安装了setuptools和scrapy。出于某种原因,当我把

scrapy --version

我收到此错误:

Traceback (most recent call last):
  File "/usr/local/bin/scrapy", line 11, in <module>
    sys.exit(execute())
  File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 122, in execute
    cmds = _get_commands_dict(settings, inproject)
  File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 46, in _get_commands_dict
    cmds = _get_commands_from_module('scrapy.commands', inproject)
  File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 29, in _get_commands_from_module
    for cmd in _iter_command_classes(module):
  File "/usr/local/lib/python2.7/dist-packages/scrapy/cmdline.py", line 20, in _iter_command_classes
    for module in walk_modules(module_name):
  File "/usr/local/lib/python2.7/dist-packages/scrapy/utils/misc.py", line 68, in walk_modules
    submod = import_module(fullpath)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/dist-packages/scrapy/commands/bench.py", line 2, in <module>
    from scrapy.tests.spiders import FollowAllSpider
ImportError: No module named tests.spiders

任何想法会是什么?

2 个答案:

答案 0 :(得分:1)

在Github上提交了构建0.24.3的问题。 要解决您的问题,只需在终端输入:

sudo pip install scrapy --upgrade

这会将您的Scrapy版本升级到0.24.4。

答案 1 :(得分:0)

参考stackoverflow.com/q/25218633/190597。这将解决问题。或者至少在我的情况下。 尝试使用以下方法卸载旧版本的scrapy:

pip uninstall Scrapy

然后使用pip使用此命令再次安装它:

pip install scrapy==0.24.2

请不要忘记事先安装python开发包。如果安装不正确,这将引发另一个问题。