ModuleNotFoundError: No module named 'utils.json_util'; 'utils' is not a package
I've added these lines of code in comfyui_to_python.py:
but now:
(env) (base) PS D:\pinokio\api\comfy.git\app\custom_nodes\ComfyUI-to-Python-Extension> python comfyui_to_python.py
current_dir:D:\pinokio\api\comfy.git\app\custom_nodes\ComfyUI-to-Python-Extension
Traceback (most recent call last):
File "D:\pinokio\api\comfy.git\app\custom_nodes\ComfyUI-to-Python-Extension\comfyui_to_python.py", line 649, in
Same for me, unfortunately, it seems to be a comfyUI itself issue.
I have the same problem, is there any solution?
Module Import Issue: ModuleNotFoundError: No module named 'utils.json_util'
Issue Summary
We encountered an issue where utils.json_util is not recognized as a module when running:
PYTHONPATH=/workspace/ComfyUI python3 -m custom_nodes.ComfyUI-to-Python-Extension.comfyui_to_python -f relighting_v6.json
Despite utils/ existing inside /workspace/ComfyUI/, Python fails to import it:
ModuleNotFoundError: No module named 'utils.json_util'; 'utils' is not a package
Adding debug logs shows /workspace/ComfyUI is in sys.path, and import utils.json_util works inside a Python shell, but the script still fails.
Steps Taken to Debug
- Verified that
/workspace/ComfyUI/utils/json_util.pyexists and has an__init__.py. - Confirmed the import works manually in a Python shell:
import utils.json_util print(utils.json_util) - Checked
sys.pathbefore failure and ensured/workspace/ComfyUIwas included. - Manually forced
/workspace/ComfyUIat the top ofsys.pathinsidecomfyui_to_python.py:import sys sys.path.insert(0, "/workspace/ComfyUI") - Removed
/workspace/ComfyUI/comfyfromsys.path, as it was interfering with imports. - Cleared all
__pycache__and.pycfiles and restarted the environment:find /workspace/ComfyUI -name "__pycache__" -type d -exec rm -r {} + find /workspace/ComfyUI -name "*.pyc" -delete
Current Behavior
- Python still throws:
when running the script.ModuleNotFoundError: No module named 'utils.json_util'; 'utils' is not a package - However,
import utils.json_utilworks in an interactive Python shell.
这是来自QQ邮箱的假期自动回复邮件。您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
Try rename the folder 'utils' in ComfyUI folder to another one, e.g. 'utilities'.
'utils' may conflicts with utils.py in the comfyui folder.
Do remember do the ‘rename refactoring’, make sure references are renamed too.
Try rename the folder 'utils' in ComfyUI folder to another one, e.g. 'utilities'.
'utils' may conflicts with utils.py in the comfyui folder.
Do remember do the ‘rename refactoring’, make sure references are renamed too. Good method, the test can pass, thank you
that probably works given I've stumbled on the same issue earlier with restricted naming being used for directories, I ended up just copying over what I needed from utils.
Same issue here.
And I suppose that the
sys.path.insert(0, ... in nodes.py
may cause a ambiguity between utils/ and comfy/utils.py
a simple alternative way: add the only function merge_json_recursive from ComfyUI/utils/json_util.py to ComfyUI/app/custom_node_manager.py, and comment out the import line from utils.json_util import merge_json_recursive
It is recommended to use portable comfyui instead of desktop version, and then use my pr version, https://github.com/pydn/ComfyUI-to-Python-Extension/pull/133