comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
56.16k stars 5.95k forks source link

TypeError: string indices must be integers, not 'str' in ComfyUI better_combos.py #3114

Closed fememystic closed 1 week ago

fememystic commented 7 months ago

I'm encountering an error while running ComfyUI, The error occurs in the better_combos.py script, specifically in the populate_items function at line 98:

names.sort(key=lambda i: i["content"].lower()) This line is trying to sort a list names using the lowercase of the "content" key as the sorting key for each element. However, it seems that the elements in the names list are strings, not dictionaries, causing the error TypeError: string indices must be integers, not 'str'.

This is what AI told me :D

I've tried to debug the issue, but I'm not sure how to resolve it. Can someone please guide me on how to fix this error? Is there an issue with the data structure being passed to the populate_items function, or is there a problem with the sorting logic itself?

Any help or suggestions would be greatly appreciated. I'm happy to provide additional information or context if needed.

The full code:

Starting server

To see the GUI go to: http://127.0.0.1:8188/

FETCH DATA from: D:\_AI\ComfyUI\custom_nodes\ComfyUI-Manager\extension-node-map.json

(pysssss:better_combos) Unable to get path for checkpoints ip-adapter-faceid-plusv2_sd15.bin

(pysssss:better_combos) Unable to get path for checkpoints ip-adapter-faceid-plusv2_sdxl_lora.safetensors

(pysssss:better_combos) Unable to get path for checkpoints ip-adapter-faceid-portrait-v11_sd15.bin

[ERROR] An error occurred while retrieving information for the 'CheckpointLoader|pysssss' node.

Traceback (most recent call last):

File "D:\_AI\ComfyUI\server.py", line 420, in get_object_info

out[x] = node_info(x)

^^^^^^^^^^^^

File "D:\_AI\ComfyUI\server.py", line 398, in node_info

info['input'] = obj_class.INPUT_TYPES()

^^^^^^^^^^^^^^^^^^^^^^^

File "D:\_AI\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts\py\better_combos.py", line 119, in INPUT_TYPES

populate_items(names, "checkpoints")

File "D:\_AI\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts\py\better_combos.py", line 98, in populate_items

names.sort(key=lambda i: i["content"].lower())

File "D:\_AI\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts\py\better_combos.py", line 98, in <lambda>

names.sort(key=lambda i: i["content"].lower())

~^^^^^^^^^^^

TypeError: string indices must be integers, not 'str'

Error: OpenAI API key is invalid OpenAI features wont work for you

QualityOfLifeSuit_Omar92::NSP ready

FETCH DATA from: D:\_AI\ComfyUI\custom_nodes\ComfyUI-Manager\extension-node-map.json

(pysssss:better_combos) Unable to get path for checkpoints ip-adapter-faceid-plusv2_sd15.bin

(pysssss:better_combos) Unable to get path for checkpoints ip-adapter-faceid-plusv2_sdxl_lora.safetensors

(pysssss:better_combos) Unable to get path for checkpoints ip-adapter-faceid-portrait-v11_sd15.bin

[ERROR] An error occurred while retrieving information for the 'CheckpointLoader|pysssss' node.

Traceback (most recent call last):

File "D:\_AI\ComfyUI\server.py", line 420, in get_object_info

out[x] = node_info(x)

^^^^^^^^^^^^

File "D:\_AI\ComfyUI\server.py", line 398, in node_info

info['input'] = obj_class.INPUT_TYPES()

^^^^^^^^^^^^^^^^^^^^^^^

File "D:\_AI\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts\py\better_combos.py", line 119, in INPUT_TYPES

populate_items(names, "checkpoints")

File "D:\_AI\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts\py\better_combos.py", line 98, in populate_items

names.sort(key=lambda i: i["content"].lower())

File "D:\_AI\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts\py\better_combos.py", line 98, in <lambda>

names.sort(key=lambda i: i["content"].lower())

~^^^^^^^^^^^

TypeError: string indices must be integers, not 'str'
sosagarcia commented 5 months ago

Hi ! I'm having the same error. The strange thing is that yesterday everything was working normally and today when it loads I'm having this error:

[ERROR] An error occurred while retrieving information for the 'CheckpointLoader|pysssss' node.
Traceback (most recent call last):
  File "E:\AI\ComfyUi\ComfyUI\server.py", line 415, in get_object_info
    out[x] = node_info(x)
             ^^^^^^^^^^^^
  File "E:\AI\ComfyUi\ComfyUI\server.py", line 393, in node_info
    info['input'] = obj_class.INPUT_TYPES()
                    ^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\AI\ComfyUi\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts\py\better_combos.py", line 119, in INPUT_TYPES
    populate_items(names, "checkpoints")
  File "E:\AI\ComfyUi\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts\py\better_combos.py", line 98, in populate_items
    names.sort(key=lambda i: i["content"].lower())
  File "E:\AI\ComfyUi\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts\py\better_combos.py", line 98, in <lambda>
    names.sort(key=lambda i: i["content"].lower())
                             ~^^^^^^^^^^^
TypeError: string indices must be integers, not 'str'

Also when I try to load a model/vae I have :

!!! Exception during processing!!! 'NoneType' object has no attribute 'lower'
Traceback (most recent call last):
  File "E:\AI\ComfyUi\ComfyUI\execution.py", line 151, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\AI\ComfyUi\ComfyUI\execution.py", line 81, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\AI\ComfyUi\ComfyUI\execution.py", line 74, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\AI\ComfyUi\ComfyUI\nodes.py", line 689, in load_vae
    sd = comfy.utils.load_torch_file(vae_path)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\AI\ComfyUi\ComfyUI\comfy\utils.py", line 13, in load_torch_file
    if ckpt.lower().endswith(".safetensors"):
       ^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'lower'
ltdrdata commented 1 week ago

Its seems that your ComfyUI-Custom-Scripts is outdated. If you continue experiencing errors, please inquire at the ComfyUI-Custom-Scripts repo https://github.com/pythongosssss/ComfyUI-Custom-Scripts

mcjavar commented 1 week ago

pulled the latest custom scripts but still the same