作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在命令行上,我正在执行以下调用 scrapy 的简单尝试:
scrapy version
我收到以下错误:
$ scrapy version
Traceback (most recent call last):
File "/Users/nathanielford/virtualenvironments/crawler/bin/scrapy", line 11, in <module>
sys.exit(execute())
File "/Users/nathanielford/virtualenvironments/crawler/lib/python3.5/site-packages/scrapy/cmdline.py", line 141, in execute
cmd.crawler_process = CrawlerProcess(settings)
File "/Users/nathanielford/virtualenvironments/crawler/lib/python3.5/site-packages/scrapy/crawler.py", line 238, in __init__
super(CrawlerProcess, self).__init__(settings)
File "/Users/nathanielford/virtualenvironments/crawler/lib/python3.5/site-packages/scrapy/crawler.py", line 129, in __init__
self.spider_loader = _get_spider_loader(settings)
File "/Users/nathanielford/virtualenvironments/crawler/lib/python3.5/site-packages/scrapy/crawler.py", line 325, in _get_spider_loader
return loader_cls.from_settings(settings.frozencopy())
File "/Users/nathanielford/virtualenvironments/crawler/lib/python3.5/site-packages/scrapy/spiderloader.py", line 33, in from_settings
return cls(settings)
File "/Users/nathanielford/virtualenvironments/crawler/lib/python3.5/site-packages/scrapy/spiderloader.py", line 20, in __init__
self._load_all_spiders()
File "/Users/nathanielford/virtualenvironments/crawler/lib/python3.5/site-packages/scrapy/spiderloader.py", line 28, in _load_all_spiders
for module in walk_modules(name):
File "/Users/nathanielford/virtualenvironments/crawler/lib/python3.5/site-packages/scrapy/utils/misc.py", line 63, in walk_modules
mod = import_module(path)
File "/Users/nathanielford/virtualenvironments/crawler/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'spiders'
如果我离开我的项目目录,错误不再发生:
$ scrapy version
Scrapy 1.2.2
是什么导致了 ImportError: No module named 'spiders'
?
最佳答案
此错误是由我的 settings.py
文件引起的,其中我有以下内容:
SPIDER_MODULES = ['spiders']
虽然它在 scrapy
提供的默认项目中,但我已经移动了那个模块。该列表中的值需要是完全限定的模块名称:即使是简单的 scrapy
执行也会加载设置文件,从而尝试从您的项目中导入模块。如果它可以找到设置文件,则它需要是正确的。
关于python - 导入错误 : No module named 'spiders' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41028605/
我是一名优秀的程序员,十分优秀!