Reputation: 1
I am using Python 3.11.4 and want to install Fiftyone.
I used pip install fiftyone
command on Command Prompt. But when I used import fiftyone as fo
it reported ImportError: DLL load failed while importing cv2: The specified module could not be found.
. When I import cv2
, it shows the same error.
I tried:
pip install opencv-python
pip install opencv-contrib-python
Or even upgrade/downgrade fiftyone & python version. But it is still impossible to solve the problem. I also tried many other ways I found on the internet but still could not solve the problem. I also tried to reset the window and tried it again but still could not solve it. While I tried on another computer, it worked immediately without any errors. I was really helpless and didn't know what to do. I really need help, please :(
Upvotes: -1
Views: 544
Reputation: 29
I came across this error when deploying my application along with the embedded python distribution. I had added pip to the embedded distribution, a Lib/site-packages folder and installed a number of packages to the embedded distribution.
With the help of the answer from @tbrugere, I used DUMPBIN with the /DEPENDENTS option on cv2.pyd and found the only dependency not in the SyWOW64 directory was python3.dll. The target machine was a newly created VM without python installed.
Copying python3.dll from the embedded distribution's top level folder to the Lib/site-packages/cv2 folder did the trick.
Upvotes: 0
Reputation: 1623
From the opencv-python readme
Q: Import fails on Windows: ImportError: DLL load failed: The specified module could not be found.?
A: If the import fails on Windows, make sure you have Visual C++ redistributable 2015 installed. If you are using older Windows version than Windows 10 and latest system updates are not installed, Universal C Runtime might be also required.
Windows N and KN editions do not include Media Feature Pack which is required by OpenCV. If you are using Windows N or KN edition, please install also Windows Media Feature Pack.
If you have Windows Server 2012+, media DLLs are probably missing too; please install the Feature called "Media Foundation" in the Server Manager. Beware, some posts advise to install "Windows Server Essentials Media Pack", but this one requires the "Windows Server Essentials Experience" role, and this role will deeply affect your Windows Server configuration (by enforcing active directory integration etc.); so just installing the "Media Foundation" should be a safer choice.
If the above does not help, check if you are using Anaconda. Old Anaconda versions have a bug which causes the error, see this issue for a manual fix.
If you still encounter the error after you have checked all the previous solutions, download Dependencies and open the cv2.pyd (located usually at C:\Users\username\AppData\Local\Programs\Python\PythonXX\Lib\site-packages\cv2) file with it to debug missing DLL issues.
Upvotes: 0