通过startproject创建Scrapy项目时出错

时间:2014-08-09 12:34:49

标签: python python-2.7 scrapy

我正在学习Scrapy框架。我刚刚开始,所以这似乎是一个新手的怀疑。但是,这里有。

我使用startproject命令创建项目。但是,无法创建项目。它给了我以下错误。

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

创建项目失败的原因是什么? 我搜索谷歌这个错误但我无法得到任何东西。

如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

我还不确定确切的原因,但这似乎与Scrapy 0.24.3有关。如果您已经通过pip安装,正在运行

pip install scrapy==0.24.2

在Windows上为我解决了这个问题。

在Ubuntu上(我从Scrapy的存储库中安装了他们的指示)我不得不点击卸载scrapy然后运行上面的命令。

我去报告了这个错误,但它看起来已经存在了: https://github.com/scrapy/scrapy/issues/848