ImportError: DLL load failed while importing cv2 - python

When I install OpenCV, I get an error as shown below. What should I do?
ImportError: DLL load failed: The specified module could not be found.

Installing OpenCV
To install a package in Jupyter Notebook, you can use the magic %pip command.
%pip install opencv-python
If the above command doesn't work on IPython < 7.3, you can try this command instead.
!pip install --user opencv-python
Demonstration
Let's see it in action. First, you insert a new cell, type in either of the two commands above, and then execute the cell using the Ctrl + Enter shortcut.
You should now be able to import and use OpenCV without any errors.

This is usually a dependency issue. Just .pyd is not enough (all .DLLs are required).
On Windows add entries to .dll into PATH environment variable (not enough for Python 3.8 with updated security policies)

Related

How to fix an error about PATH when installing tensorflow on windows?

I tried to install tensorflow, but I got the following error:
My Command:
pip install tensorflow
The Error I got:
ERROR: Could not install packages due to an OSError:
[Errno 2] No such file or directory:
'C:\\Users\\sipha\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0
\\LocalCache\\local-packages\\Python310\\site-packages\\tensorflow\\include
\\external\\com_github_grpc_grpc\\src\\core\\ext\\filters\\client_channel
\\lb_policy\\grpclb\\client_load_reporting_filter.h'
HINT: This error might have occurred since this system does not have
Windows Long Path support enabled. You can find information on how to
enable this at https://pip.pypa.io/warnings/enable-long-paths
anyone know how to make new envirenment?
install tensoCMDrflow on windows, worked with CMD.
have python version 3.10
It seems like Long Path is disabled on your PC.
Do the following to enable it, and then try to install Tensorflow.
Press the Windows key + R key.
Type regedit and press enter.
Navigate to the following location Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem in the registry editor(regedit), or you could just paste it in the search bar on top.
Find and right click on LongPathsEnabled
Set the DWORD value to 1 instead of zero and reboot your computer.
This will enable Long Path support. Then try to install Tensorflow again.
You could reference the following article if you need any help https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/.
try conda install instead of pip install if you have conda installed
conda install tensorflow==2.6.0

Anaconda "import georaster" error: specified module not found

I am using Anaconda3 5.2.0 for Windows 10 64 bit, which is python 3.6.5 (Anaconda3-5.2.0-Windows-x86_64.exe). I have installed this into C:\Anaconda3 and then from the anaconda prompt installed basemap:
conda install -c conda-forge basemap
conda install -c conda-forge basemap-data-files
I have used this to start building map files and everything is working fine. I then wanted to add a raster to the map using georaster.
conda install -c conda-forge georaster
This also installs gdal.
When I open Jupyter Notebook and enter the line
import georaster
I get the following error message:
ImportError: DLL load failed: The specified module could not be found.
I have tried various solutions that I have seen for related issues including installing a gdal update, fiona, and geopandas. None of these change the message.
I tried installing gdal using the binaries .whl file in conda, but despite following the advice (which said to use pip) I was not able to make it work.
pip install GDAL-2.2.4-cp37-cp37m-win_amd64.whl
resulted in an error message:
GDAL-2.2.4-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.
Finally I went looking to see if I could locate the missing DLL manually. I saw one user suggest libtiff.dll was the missing file, and indeed it was one I did not have. I downloaded it and copied it into the System32 and SysWOW64 folders. This still resulted in an error but changed the error message:
ImportError: DLL load failed: %1 is not a valid Win32 application.
However I could not find a way to stop the error from occurring. I followed the steps to register the .dll but that also had an error message from not found to not supported:
(cmd prompt in administrator mode)
regsvr32.exe /i libtiff.dll
The module "libtiff.dll" failed to load.
Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files.
The specified module could not be found.
I have tried downloading from 2 other websites, neither with any success. It is feeling like every method I attempt now just hits some weird error that nobody else is seeming to have and I don't understand why.
If anyone could offer some advice I'd be very appreciative. Thank you in advance.
downloading the required *.whl file(GDAL-2.2.4-cp36-cp36m-win_amd64.whl) from https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal and then copying it to a location like C:\GDAL-2.2.4-cp36-cp36m-win_amd64.whl
then pip install c:\GDAL-2.2.4-cp36-cp36m-win_amd64.whl
worked for me.
Thanks.

Failed to import Sklearn

I am trying to build a recommender system with Python. However, I can't proceed since I get an import error of Sklearn everytime.
I get this error:
"ImportError: DLL load failed: Can't find module."
How do i fix this? (The last sentence in the error is in Dutch btw)
A screenshot of my error is below.
By the way: I get the same import error for Seaborn
Windows 10 + Visual Studio Code - "CMD + SHIFT + P" from within visual studio code and search for "Select Interpreter" clicking on this will show a list of available python interpreters and versions installed on your system that are detected by visual studio code and your currently selected environment. (Visual Studio Code usually incorrectly defaults to 32 bit interpreter)
Ensure you have the correct python environment (where you have the required libraries & "packages" installed)
This should fix your import issue if you have the libraries installed. Use the appropriate cmd line tool to install packages. If you are using Anaconda - use Conda Install or use pip etc...
Scikit-learn uses numpy and scipy. Those modules are using C and Fortran code that needs to be compiled. Nonetheless, Windows cannot compile them right away.
I would recommend you to download Anaconda and install scikit-learn like this. (You may need to add conda to path)
Another method is to download precompiled binary from this page. Then run:
pip uninstall scikit-learn
pip install <numpy-wheel>
pip install <scipy-wheel>
pip install <scikit-wheel>

No module found cv2 in IDLE

I am trying to install opencv3.0 on my ubuntu system. I installed it according to link : http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/#comment-429946
At the end, in the terminal,when I try to import cv2, it works. But in the python IDLE it does not work. It gives the error : "No module named cv2".
Also, whenever I try to enter workon cv command, it says : "Error: deactivate must be sourced. Run 'source deactivate'instead of'deactivate'."
Althoug it gives error, I can get in cv environment((cv) ali#ali-pc:~$ ).
I am new to ubuntu and opencv. Thanks
Maybe its because of your IDLE interpreter settings. I use Pycharm and set to project interpreter path to my virtualenv interpreter with installed opencv-python. After this import works.
Try by giving version
pip install opencv==4.1.0.25(latest version)
Check
pip list
If not listed search location of python
which python
Search for site-packages folder inside resultant location of 'python' (usually under lib/python3.5/site-packages) and check if opencv-python present or not(packages are not installing right location)
sudo apt-get install opencv-python

Run Menpo and Menpofit with PyCharm

I trying to explore Menpo and Menpofit with PyCharm IDE. I have installed required packages but I have some issue:
from .fastpwa import CLookupPWA;
ImportError: cannot import name 'CLookupPWA'
from .normals import compute_normals;
ImportError: No module named 'menpo.shape.mesh.normals'
So how I can run Menpo and Menpofit with PyCharm?
How did you install the required packages? With the conda instructions, or via pip?
The error you are seeing there is because CLookupPWA and compute_normals are compiled Python extensions that need to be built before the package can be loaded. The easiest way to do this is to use the make command in the Menpo top level, which runs python setup.py build_ext --inplace.
If you are on Windows, things start to get pretty tricky, because you need to be able to compile the code properly. Take a look at the instructions here which try to explain how to properly set up Visual Studio 2008.

Categories