'NoneType' object is not iterable -------- [程序异常退出,退出代码为 1 (0x00000001)]
🚨 错误信息
(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. 预防措施
None的对象。os.path.exists验证路径有效性,用try-except捕获读取异常。pydantic验证配置结构,或用logging记录配置加载状态。---
注:若配置文件确实缺失,需创建extra_model_paths.yaml(或对应格式),按ComfyUI文档填写路径映射。