Closed shamanicvocalarts closed 1 week ago
I've pushed a fix here: https://github.com/replicate/comfyui-replicate/commit/f221cd3eb4f7a11e79ceb5c567dae208fc214c8d
Please can you confirm if this works for you.
Tried with latest build but got this error
Traceback (most recent call last):
File "C:\Users\Lucas\Documents\StabilityMatrix-win-x64\Data\Packages\ComfyUI\nodes.py", line 1906, in load_custom_node
module_spec.loader.exec_module(module)
File "
Cannot import C:\Users\Lucas\Documents\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\comfyui-replicate module for custom nodes: 'charmap' codec can't decode byte 0x8f in position 2327: character maps to
for context, my local build still works, & in that one I only modified
def create_comfyui_nodes_from_schemas(schemas_dir): nodes = {} current_path = os.path.dirname(os.path.abspath(file)) schemas_dir_path = os.path.join(current_path, schemas_dir) for schema_file in os.listdir(schemas_dir_path): if schema_file.endswith(".json"): with open(os.path.join(schemas_dir_path, schema_file), "r", encoding="utf-8") as f: schema = json.load(f) node_name, node_class = create_comfyui_node(schema) nodes[node_name] = node_class return nodes
Ahh, I've fixed this too now in https://github.com/replicate/comfyui-replicate/commit/8bf6e0b2e0a4c9319baa241f2fea1b5a8fd800e5
Just tested & can confirm it works.
I was getting this error when attempting to launch the replicate nodes on windows. I was able to resolve the issue locally by changing the default encoding for JSON files to UTF8 , here is the issue according to GPT4 :
Issue: UnicodeDecodeError when loading JSON files on Windows Description: When trying to load JSON schema files on a Windows environment, the following error occurs:
arduino Copy code File "C:\Users\Lucas\Documents\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\comfyui-replicate\node.py", line 139, in create_comfyui_nodes_from_schemas schema = json.load(f) File "json__init__.py", line 293, in load File "encodings\cp1252.py", line 23, in decode UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 2327: character maps to
Environment:
OS: Windows Package: ComfyUI Custom Node Module: comfyui-replicate Steps to Reproduce:
Place a JSON schema file with non-ASCII characters in the schemas directory. Run the ComfyUI custom node script that attempts to load these schema files. The UnicodeDecodeError is thrown when the script tries to decode the JSON file using the default cp1252 encoding. Analysis: The issue is due to the default encoding used by the open function on Windows, which is cp1252. This encoding cannot decode certain non-ASCII characters present in the JSON files. The fix involves explicitly specifying the utf-8 encoding when opening the JSON files.
Suggested Fix: Modify the create_comfyui_nodes_from_schemas function to include encoding="utf-8" when opening the JSON files. Below is the updated code snippet:
python Copy code import os import json
def create_comfyui_nodes_from_schemas(schemas_dir): nodes = {} current_path = os.path.dirname(os.path.abspath(file)) schemas_dir_path = os.path.join(current_path, schemas_dir) for schema_file in os.listdir(schemas_dir_path): if schema_file.endswith(".json"): with open(os.path.join(schemas_dir_path, schema_file), "r", encoding="utf-8") as f: schema = json.load(f) node_name, node_class = create_comfyui_node(schema) nodes[node_name] = node_class return nodes
Example usage
schemas_dir = "schemas" # Replace with the actual directory name nodes = create_comfyui_nodes_from_schemas(schemas_dir) Impact: This change ensures that the file is read using UTF-8 encoding, which supports all Unicode characters and prevents the UnicodeDecodeError.
Additional Notes:
This issue is specific to Windows due to its default encoding settings. Unix-based systems (Linux, macOS) default to UTF-8 and do not typically encounter this issue. Ensure that all JSON files are saved with UTF-8 encoding to avoid similar issues.