Closed noytam closed 11 months ago
Yes, it happens sometimes that Insightface cannot be built even if C++ BT installed, but normally it works ok
I had this issue but i think it was more related to me lazily installing Python multiple times and then not even declaring paths properly. However in the interest of trying to figure things out i decided to try to create workarounds without uninstalling Python everywhere.
This assumes you've followed the troubleshooting guide and installed everything.
To Fix: If you haven't set your Path or used a venv then the insightface installed files may be wherever your Python is installed. For example mine i found in C:/Users/GigaNerd/AppData/Roaming/Python/Python311/site-packages/ Copy this folder to the python folder in Python_Embeded N.B Make sure in thirdparty\face3d\mesh\cython there are 3 folders called build, dist and mesh_core_cython.egg-info
This should solve your issue.
If however you have royally screwed up like i did and you are being told continually that you cannot find things even after these moves, you can change some .py files to declare locations manually.
Here are the files i've changed and it all now works: Issue 1. Error : albumenations at A Folder : ComfyUI_windows_portable/python_embeded/python311/Insightface/app/ file: mask_renderer.py Fix : Changed the first section of the file to this:
import os, sys, datetime
import numpy as np
import os.path as osp
from .face_analysis import FaceAnalysis
from ..utils import get_model_dir
from ..thirdparty import face3d
from ..data import get_image as ins_get_image
from ..utils import DEFAULT_MP_NAME
import cv2
sys.path.insert(0, 'C:/Users/GigaNerd/AppData/Roaming/Python/Python311/site-packages/')
import albumentations as A
from ..albumentations.core.transforms_interface import ImageOnlyTransform
Issue 2 Error: Issue with importlib.util.module_from_spec(spec) for some reason Folder: ComfyUI_windows_portable/python_embeded/python311/thirdparty/face3d/mesh/cython/ File: mesh_core_cython.py Fix : Changed to declare the file to use as follows
def __bootstrap__():
global __bootstrap__, __loader__, __file__
import sys, importlib.util
# Put mesh_core_cython.cp311-win_amd64.pyd in this location
__file__ = 'C:/Comfy/ComfyUI_windows_portable/python_embeded/python311/insightface/thirdparty/face3d/mesh/cython/mesh_core_cython.cp311-win_amd64.pyd'
__loader__ = None; del __bootstrap__, __loader__
spec = importlib.util.spec_from_file_location(__name__, __file__)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
__bootstrap__()
Issue 3 - cannot remember what error i had that made me do this so Error : don't remember Folder : ComfyUI_windows_portable/python_embeded/python311/thirdparty/face3d/ File : init Fix replaced the whole file
import os, sys, datetime
#import mesh
#import morphable_model
sys.path.insert(0, 'C:/Comfy/ComfyUI_windows_portable/python_embeded/insightface/')
from . import mesh
from . import morphable_model
First, confirm
What happened?
I installed on a Windows 10 machine following the instructions saying it's possible to install only VS C++ Build Tools, however when I tried this it resulted in the error "ImportError: DLL load failed while importing mesh_core_cython: The specified module could not be found".
Only the method currently found under Troubleshooting->I. worked successfully. If this issue with installing after installing only VS C++ Build Tools reproduces consistently, I think the Troubleshooting->I. instructions should be moved to the official Installation section for Windows, and the line saying only VS C++ Build Tools are possible should be removed.
Steps to reproduce the problem
Installing on Windows 10 machine following instructions in the Installation section, installing only VS C++ Build Tools.
Sysinfo
Windows 10 22H2 OS build 19045.3570
Relevant console log
Additional information
No response