问题解决:Scrapy Unknown command: crawl

今天用pycharm调试新建的scrapy-redis项目报错:

Connected to pydev debugger (build 183.4588.64)
Scrapy 1.8.0 - no active project

Unknown command: crawl

Use "scrapy" to see available commands

我没有用scrapy crawl xxx的形式运行scrapy,而是写了个启动脚本运行:

main.py:

from scrapy.cmdline import execute
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
execute(["scrapy","crawl","douban_redis"])

看了一下别人的错误报告,基本都是因为没有使用scrapy startproject xxx创建scrapy项目而导致的缺少scrapy.cfg文件,而我的项目是存在scrapy.cfg文件的。

我的目录结构:
在这里插入图片描述

于是考虑到可能是我的启动脚本有问题。可是我main.py在别的项目里是可以的,证明代码部分不存在问题。

于是考虑到可能是启动脚本的启动环境有问题,点击编辑配置在这里插入图片描述

感觉到可能是Working directory的问题。
在这里插入图片描述

看了一下正常项目的Working directory
在这里插入图片描述

果然,错误原因是运行脚本的启动环境设置错误。

发布了673 篇原创文章 · 获赞 644 · 访问量 38万+

猜你喜欢

转载自blog.csdn.net/zhaohaibo_/article/details/105277768
今日推荐