'NoneType' object is not iterable -------- [程序异常退出,退出代码为 1 (0x00000001)]

2026年03月05日 15:56 状态: processing

🚨 错误信息

(most recent call last): File "D:\comfyui\GF\ComfyUI-aki-v3_password_bilibili-秋葉aaaki\ComfyUI-aki-v3\ComfyUI\main.py", line 159, in <module> apply_custom_paths() ~~~~~~~~~~~~~~~~~~^^ File "D:\comfyui\GF\ComfyUI-aki-v3_password_bilibili-秋葉aaaki\ComfyUI-aki-v3\ComfyUI\main.py", line 80, in apply_custom_paths utils.extra_config.load_extra_path_config(extra_model_paths_config_path) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\comfyui\GF\ComfyUI-aki-v3_password_bilibili-秋葉aaaki\ComfyUI-aki-v3\ComfyUI\utils\extra_config.py", line 10, in load_extra_path_config for c in config: ^^^^^^ TypeError: 'NoneType' object is not iterable -------- [程序异常退出,退出代码为 1 (0x00000001)]

🤖 AI解决方案

报错分析报告

1.错误翻译



原文:TypeError: 'NoneType' object is not iterable
译文:类型错误:'NoneType'对象不可迭代

2. 原因分析


  • 根本原因config变量为None,但代码尝试对其执行迭代操作(for c in config)。

  • 具体位置ComfyUI/utils/extra_config.py第10行的load_extra_path_config函数内。

  • 上下文apply_custom_paths调用load_extra_path_config时传入的extra_model_paths_config_path对应配置文件未正确读取(返回None),导致后续迭代失败。
  • 3. 解决方案


    python

    修复后的代码(ComfyUI/utils/extra_config.py 第9-11行)


    def load_extra_path_config(config_path):
    config = read_config(config_path) # 原读取逻辑(假设返回None表示失败)
    if config is None: # 新增空值检查
    print(f"[WARN] 额外路径配置文件无效/不存在: {config_path},已跳过")
    return
    for c in config: # 原迭代逻辑
    # 保持原处理代码不变

    4. 预防措施


  • 最佳实践1:读取外部配置后必须做空值校验,避免直接操作可能为None的对象。

  • 最佳实践2:使用配置文件前,用os.path.exists验证路径有效性,用try-except捕获读取异常。

  • 推荐工具:用pydantic验证配置结构,或用logging记录配置加载状态。
  • ---
    :若配置文件确实缺失,需创建extra_model_paths.yaml(或对应格式),按ComfyUI文档填写路径映射。