insightface icon indicating copy to clipboard operation
insightface copied to clipboard

Import issue because of missing __init__.py file

Open dzynerboy opened this issue 11 months ago • 4 comments

Trying to install into ComfyUI but upon bootup, the system is kicking back an error when it tries to import Insightface due to a missing init.py file

FileNotFoundError: [Errno 2] No such file or directory: '/Users/john/AI/ComfyUI/custom_nodes/insightface/init.py'

Cannot import /Users/john/AI/ComfyUI/custom_nodes/insightface module for custom nodes: [Errno 2] No such file or directory: '/Users/john/AI/ComfyUI/custom_nodes/insightface/init.py'

Import times for custom nodes: 0.0 seconds: /Users/john/AI/ComfyUI/custom_nodes/websocket_image_save.py 0.0 seconds (IMPORT FAILED): /Users/john/AI/ComfyUI/custom_nodes/insightface 0.0 seconds: /Users/john/AI/ComfyUI/custom_nodes/ComfyUI_IPAdapter_plus 0.0 seconds: /Users/john/AI/ComfyUI/custom_nodes/ComfyUI_essentials 0.1 seconds: /Users/john/AI/ComfyUI/custom_nodes/ComfyUI-Manager 0.4 seconds: /Users/john/AI/ComfyUI/custom_nodes/comfyui_controlnet_aux

Anyone else having this issue?

Mac Studio M2 Ultra

dzynerboy avatar Dec 15 '24 16:12 dzynerboy

ChatGPT and I have sat for several hours trying to resolve this issue.

I've tried creating an empty .py file - No good.

I get this message -

Skip /Users/john/AI/ComfyUI/custom_nodes/insightface module for custom nodes due to the lack of NODE_CLASS_MAPPINGS.

I've tried to use Manager in comfyUI to install missing custom nodes - no luck

dzynerboy avatar Dec 15 '24 16:12 dzynerboy

ChatGPT is saying that I need to define Node classes using the NODE_CLASS_MAPPINGS command line

NODE_CLASS_MAPPINGS = { "CustomNode1": CustomNodeClass1, "CustomNode2": CustomNodeClass2, }

¯_(ツ)_/¯

Any thoughts from the humans out there?

dzynerboy avatar Dec 15 '24 16:12 dzynerboy

Ok chatGPT coached me to create my own init.py file and then put the following code into it:

class ExampleNode: def init(self): # This is just a placeholder node class print("ExampleNode initialized!")

Define the NODE_CLASS_MAPPINGS dictionary

NODE_CLASS_MAPPINGS = { "ExampleNode": ExampleNode, # Key: "Name of the Node", Value: The Node Class }

ERRORS are gone!!!!!

Import times for custom nodes: 0.0 seconds: /Users/john/AI/ComfyUI/custom_nodes/websocket_image_save.py 0.0 seconds: /Users/john/AI/ComfyUI/custom_nodes/insightface 0.0 seconds: /Users/john/AI/ComfyUI/custom_nodes/ComfyUI_IPAdapter_plus 0.0 seconds: /Users/john/AI/ComfyUI/custom_nodes/ComfyUI_essentials 0.1 seconds: /Users/john/AI/ComfyUI/custom_nodes/ComfyUI-Manager 0.3 seconds: /Users/john/AI/ComfyUI/custom_nodes/comfyui_controlnet_aux

Starting server

dzynerboy avatar Dec 15 '24 16:12 dzynerboy

WHERE did you add that text in the init file ? Been struggling with this on My Studio M2 Ultra I have the init py file but also have the node class mappings problem. Skip /Users/mo-ry/1AyEye/COMFYUI_PY311/ComfyUI/custom_nodes/insightface module for custom nodes due to the lack of NODE_CLASS_MAPPINGS.

My init py file looks like this:


coding: utf-8

pylint: disable=wrong-import-position

"""InsightFace: A Face Analysis Toolkit.""" from future import absolute_import

try: #import mxnet as mx import onnxruntime except ImportError: raise ImportError( "Unable to import dependency onnxruntime. " )

version = '0.7.3'

from . import model_zoo from . import utils from . import app from . import data from . import thirdparty

polarNerd204 avatar Mar 13 '25 01:03 polarNerd204