INFO: Could not find files for the given pattern(s) message appears on Windows

用户在 Windows 11(或部分 Windows 10 版本)上运行基于 Gradio 5.6.0 及以上版本编写的 Python WebUI 应用时(例如 demo.launch() ),控制台无端打印 INFO: Could not find files for the given patt

INFO: Could not find files for the given pattern(s) message appears on Windows

INFO: Could not find files for the given pattern(s) message appears on Windows

快速结论:该报错发生在 Windows 系统下启动 Gradio 应用(5.6.0+)时,根本原因是 Gradio 内部探测 Node.js 安装路径的 where node 命令输出被泄漏到控制台。若系统未安装 Node.js 或不位于 PATH,该消息每次启动必现。

问题场景

用户在 Windows 11(或部分 Windows 10 版本)上运行基于 Gradio 5.6.0 及以上版本编写的 Python WebUI 应用时(例如 demo.launch()),控制台无端打印 INFO: Could not find files for the given pattern(s). 消息。即使将 Python logging 设置为 logging.NullHandler(),该消息依然出现,表明它不是由 Python logging 模块发出的。

报错原文

INFO: Could not find files for the given pattern(s).

原因分析

该报错由 Gradio gradio/utils.pyget_node_path() 函数内部调用 Windows where 命令探测 Node.js 路径时产生。具体来说,当系统未安装 Node.js 或 node 不在系统 PATH 中时,subprocess.check_output(["where", "node"]) 只捕获了 stdout,而 where 命令将报错信息写入 stderr——该 stderr 泄漏到用户控制台,从而显示 INFO: Could not find files for the given pattern(s).。该消息在 Linux 下不会出现(使用 which 命令的行为不同),也不影响 Gradio 正常功能。

环境排查

  • 确认操作系统是否为 Windows 11 或部分 Windows 10。
  • 检查系统中是否安装了 Node.js(node --version);若未安装,则可能触发该信息。
  • 确认 Gradio 版本是否为 5.6.0 或更高(小于 5.6.0 无此问题)。
  • 不影响 Python、PyTorch、CUDA 等环境配置。

解决步骤

  1. 可优先尝试:安装 Node.js(确保 node 位于系统 PATH 中),重新启动应用,消息应消失。
  2. 若不想安装 Node.js,可自行修改 Gradio 源码中的 gradio/utils.py 文件,定位到 def get_node_path() 函数,将:
    windows_path = subprocess.check_output(["where", "node"]).decode().strip().split("\r\n")[0]

    修改为:

    windows_path = subprocess.check_output(["where", "node"], stderr=subprocess.DEVNULL).decode().strip().split("\r\n")[0]

    (注意:此修改为非官方修改,仅在 Issue 讨论中被社区验证有效)

  3. 等待 Gradio 官方合并修复 PR(已确认修复方案为 stderr=subprocess.DEVNULL,参考 Puneet15556 的修复分支)。

验证方法

重启 Gradio 应用后,观察控制台是否仍然打印 INFO: Could not find files for the given pattern(s).。若该行消失,则表示问题已解决。

参考来源

gradio-app/gradio #9974

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 14745

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注