windows import faiss error:DLL load failed

Viewed 4164

I install faiss-cpu form pypi.org

But when I use this code:

import faiss

the error message is:

ImportError                               Traceback (most recent call last)
~\Anaconda3\lib\site-packages\faiss\loader.py in <module>
     33         logger.info("Loading faiss.")
---> 34         from .swigfaiss import *
     35 

~\Anaconda3\lib\site-packages\faiss\swigfaiss.py in <module>
     12 if __package__ or "." in __name__:
---> 13     from . import _swigfaiss
     14 else:

ImportError: DLL load failed: The specified module could not be found.

How to fix it?

3 Answers

If you have installed faiss using pip. Then use

conda install -c conda-forge faiss

In anaconda prompt.

Add your DLL location of python (C:\Program Files\Python<version.no>\DLLs) in Environment variables of Path

The faiss on PyPi is, according to the project description, It says

an Unofficial prebuilt binary for Linux and MacOS.

It seems you have to switch to Linux or MacOS to run it. But you are running on windows, which is not supported. You can read the official installation instructions for Faiss.

Related