关于scrapy在pycharm中run可以运行,但是debug不行的问题

关于scrapy在pycharm中run模式可以运行,但是debug模式不行的问题

文章目录

点击run就可以运行,但是debug就是运行不了

一点击debug就报这个错,也不知道啥原因

报错:

log 复制代码
[asyncio] ERROR: Exception in callback <Task pending name='Task-1' coro=<ExecutionEngine.open_spider() running at E:\code\top_baidu_crawl\venv\Lib\site-packages\scrapy\core\engine.py:406> cb=[Deferred.fromFuture.<locals>.adapt() at E:\code\top_baidu_crawl\venv\Lib\site-packages\twisted\internet\defer.py:1251]>()
handle: <Handle <Task pending name='Task-1' coro=<ExecutionEngine.open_spider() running at E:\code\top_baidu_crawl\venv\Lib\site-packages\scrapy\core\engine.py:406> cb=[Deferred.fromFuture.<locals>.adapt() at E:\code\top_baidu_crawl\venv\Lib\site-packages\twisted\internet\defer.py:1251]>()>
Traceback (most recent call last):
  File "D:\python3.12.1\Lib\asyncio\events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
TypeError: 'Task' object is not callable

解决方案

双击shift------搜索registry------找到 python.debug.asyncio.repl------取消勾选------保存

这个勾选去掉,就可以正常debug了,

查了下原因

在 PyCharm 中,python.debug.asyncio.repl 是一个 注册表选项(Registry Key),用于控制调试器在处理 异步代码(asyncio) 时的行为,特别是与 调试控制台(Debug Console) 的交互相关。其核心作用如下:

功能说明

启用异步 REPL 支持:

当设置为 True 时,PyCharm 的调试控制台会支持异步交互模式。

你可以在调试过程中直接在控制台中输入await表达式(如 await some_async_function()),并立即执行异步代码。

若未启用(默认值),调试控制台可能无法直接执行 await 命令,导致异步代码调试受阻。

解决异步调试问题:

在调试异步代码时(如使用 asyncio、async/await),部分 PyCharm 版本可能存在控制台交互的兼容性问题。

启用此选项可强制调试器适配异步环境,避免出现 RuntimeError: This event loop is already running 等错误。

相关推荐
深蓝电商API19 小时前
Scrapy 爬虫监控:结合 Prometheus+Grafana 实践
爬虫·python·scrapy
停走的风19 小时前
anaconda与pycharm卸载重安装笔记
笔记·pycharm·conda
林智勇(小学信息技术高级教师)20 小时前
学习 Scratch 最好的方式
学习·scrapy
深蓝电商API1 天前
Scrapy 自定义命令与扩展:打造专属爬虫工具
爬虫·python·scrapy
TangKenny1 天前
jar 命令详解
java·pycharm·jar
wuxin_91021 天前
Android Studio打Jar包
pycharm·android studio·jar
深蓝电商API2 天前
Scrapy杜绝重复请求:Rfpdupfilter源码分析与优化
爬虫·python·scrapy
深蓝电商API2 天前
Scrapy LinkExtractor参数详解与复杂链接提取
爬虫·python·scrapy
Uncertainty!!2 天前
pycharm本地Failed to open X display(exiting)
ide·python·pycharm
勇往直前plus2 天前
解决:pycharm运行程序时出现Run ‘python tests for XXX.py‘的问题
ide·python·pycharm