sd-webui-roop icon indicating copy to clipboard operation
sd-webui-roop copied to clipboard

I did install the insightface lib, but it still report No module named 'insightface'

Open alinasama opened this issue 1 year ago • 1 comments

after I pip install insightface==0.7.3 it shows: "Successfully built insightface Installing collected packages: insightface Successfully installed insightface-0.7.3" on my cmd,

however, when I started the webui, it still can not find insightface, report like this:

_Error loading script: swapper.py Traceback (most recent call last): File "F:\novelai-webui-aki-v2\modules\scripts.py", line 263, in load_scripts script_module = script_loading.load_module(scriptfile.path) File "F:\novelai-webui-aki-v2\modules\script_loading.py", line 10, in load_module module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in call_with_frames_removed File "F:\novelai-webui-aki-v2\extensions\sd-webui-roop\scripts\swapper.py", line 12, in import insightface ModuleNotFoundError: No module named 'insightface'

Looks like it can't find the insightface library eventhough I have already installed it, any thing I could do to guide roop to find it?

alinasama avatar Jun 23 '23 17:06 alinasama

Same here. It also happens for ifnude.

I also get a ModuleNotFoundError for '_socket', but I can't install this one with a [ERROR: Invalid requirement: '_socket'] message.

alexandregoes avatar Jun 23 '23 17:06 alexandregoes

Check module installation, Double-check that the insightface module is installed correctly by running pip show insightface in your command prompt. this command will display information about the installed package, including the installation location.

spacesugam avatar Jun 23 '23 18:06 spacesugam

Ensure that you are using the same Python environment where you installed the insightface module, modules need to be installed specifically within that environment.

spacesugam avatar Jun 23 '23 18:06 spacesugam

I'm not a programmer, so I did it in a simple way. The package is installed in users\user\AppData\Local\Programs\Python\Python310\Lib\site-packages And from there I manually copied to the sd\venv\lib\site-packages folder and everything worked there are two folders insightface and insightface-0.7.3.dist-info

Salexxxx23 avatar Jun 23 '23 19:06 Salexxxx23

@spacesugam, thanks for the help! How can I change the environment?

@Salexxxx23, thanks! I copied all the packages I was getting errors and it almost worked. Now I'm only getting the following error:

ImportError: cannot import name 'mesh_core_cython' from 'insightface.thirdparty.face3d.mesh.cython' (unknown location)

alexandregoes avatar Jun 23 '23 20:06 alexandregoes

same error for me. At last I go to insightface\thirdparty\face3d\mesh\cython , open a cmd, run python setup.py build_ext -i . this works for me.

rievez avatar Aug 05 '23 07:08 rievez

Just to add to this - I was also getting 'ModuleNotFoundError for '_socket' - My solution was to uninstall Python 3.10 from the windows 'Add or Remove programs`, and download it again, reinstall but with Custom installation, and making sure to check the Add to PATH (or enviroment vars). The reason being (i think) pip install was trying to run and didnt have the right permissions / couldnt find the right executable or something along those lines. I removed my current install of Automatic1111 and reinstalled to a different path this time, and it worked.

chud37 avatar Aug 18 '23 15:08 chud37

@spacesugam, thanks for the help! How can I change the environment?

@Salexxxx23, thanks! I copied all the packages I was getting errors and it almost worked. Now I'm only getting the following error:

ImportError: cannot import name 'mesh_core_cython' from 'insightface.thirdparty.face3d.mesh.cython' (unknown location)

I got to this point without success. In the end I ended up reinstalling everything from SD, the only thing I did differently is that the install.py file did not have execution permissions, immediately after installing it I placed them. I got the same errors, but this time manually importing all the dependencies no longer gave me this error.

Checking the permits could be a good idea.

AdrianAguilarT avatar Aug 28 '23 21:08 AdrianAguilarT

I think I found the problem -- at least for me.

For me, a1111 was running its own python inside venv -- which is located in automatic1111/venv/scripts/python.exe -- not the global python install. So when I was doing pip install insightface==0.7.3 it was installing it to the global python install, not the venv version.

So running venv\scripts\python.exe -m pip install insightface==0.7.3 instead from inside a1111 folder /should/ do it?

georgestephanis avatar Jan 24 '24 17:01 georgestephanis