DLL load failed in opencv with python - python

I wish if anyone could give me a hand with my prob,
I have installed python 3.6 amd64 and add it to path then installed opencv 3.2 successfully using "pip" ... However, when I'm trying to import the cv2 (the library of opencv) and here is the error that I have got:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv2
ImportError: DLL load failed: The module specified is not found.

Make sure that cv2.pyd is in your Python's lib\site-packages\ directory.
Also check if OPENCV_DIR = C:\Program Files\OpenCV 3.2.0\x64\vc14, or similar, is in your Windows' system variables setting. The sample path OPENCV_DIR is for the binary compiled with VC14 which is Visual Studio 2015 VC++.

I'm guessing you've installed pip2(for python2) instead of pip3.(for python3)
Try this to install pip for python3
sudo apt-get install python3-pip
Now use
pip3 install python3-opencv

Related

Why do I still get the "module not found" error even after having installed the package using pip install?

I am trying to create an image processing program using convolutions. I need the package scikit-image, specifically this:
from skimage.exposure import rescale_intensity
I have repeatedly installed scikit-image using pip install scikit-image in my terminal (Mac). I did this in the folder where my convolutions.py file is located (is this what is meant by the PYTHONPATH?). However, I always get an error message:
Traceback (most recent call last):
File "Convolutions.py", line 6, in <module>
from skimage.exposure import rescale_intensity
ImportError: No module named skimage.exposure
How do I solve the problem?
make sure you are installing the package on the same version of python which you are running. On a mac, python by default runs python-2.7, and the command python3 runs python-3.x. Also, pip by default installs packages to python-2.7. To install them on python3 try running
python3 -m pip install scikit-image
or simply
pip3 install scikit-image

Import CV2: DLL load failed: The specified module could not be found while successful pip installation

I was working with Python 3.7 and OpenCV 4.2 in Pycharm IDE (Windows10). The system environment variables were changed by one of my co-workers by accident (we don't know what happened exactly). Then I found that my code did not work with this error!:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
Then I used this command:
pip uninstall opencv-python
pip uninstall opencv-contrib-python
pip install opencv-python
All of them executed successfully, but when I write import cv2 the above error is appeared. By the way, the system knows command Python, it shows the right path to the python.exe. Moreover, commands like import numpy works correctly! How can I fix this problem?
I found the answer! There was an extra cv2.py file in site-packages/cv2 path. So, I removed it and the code worked

Python Basemap/Matplotlib Install

I am trying to install the base map for use with matplotlib python v2.7 running on Mac OSX Mavericks. I have all the latest versions of all modules (matplotlib, etc) running using anaconda, but keep getting the following error:
Traceback (most recent call last):
File "simpletest.py", line 1, in <module>
from mpl_toolkits.basemap import Basemap
File "/Users/felishalawrence/anaconda/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py", line 37, in <module>
import _geoslib.so
ImportError: dlopen(/Users/felishalawrence/anaconda/lib/python2.7/site-packages/_geoslib.so, 2): Library not loaded: libgeos_c.1.dylib
Referenced from: /Users/felishalawrence/anaconda/lib/python2.7/site-packages/_geoslib.so
Reason: no suitable image found. Did find:
/usr/local/bin/gcc-4.9/libgeos_c.1.dylib: stat() failed with errno=20
Can someone please give me an idea of what is wrong? Thanks!
Try installing the following packages with Homebrew:
brew install numpy
brew install proj
brew install geos
export GEOS_DIR="/usr/local/Cellar/geos/3.10.3/"

Lost module while installing opencv 2.4.9 for python in Windows

I try to install opencv from source. I use Visual studio 2010, python 2.7.8 and make steps like here.
The problem is that when importing cv2 I get error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv2
ImportError: DLL load failed: The specified module could not be found.
There are following cv-files in the C:\Python27\Lib\site-packages:
cv2.pyd
cv.py
cv.pyc
I also have Python 3.4.1 but CMake doesn't see that, so I think it is not the reason.
But CMake has just two lines in the PYTHON group:
PYTHON_NUMPY_INCLUDE_DIR C:/Python27/lib/site-packages/numpy/core/include
PYTHON_PACKAGES_PATH C:/Python27/Lib/site-packages
Here's what my install of OpenCV for Windows, built with MinGW for C++ includes.
It's not actually an install - the folder can be zipped and put on any computer, provided you specify to CMake the paths.

NameError: name 'freenect' is not defined

I am trying to execute a python code using a kinect
this is awesome.py:
from SimpleCV import *
import freenect
cam = Kinect()
depth = cam.getDepth()
depth.show()
and I'm getting this error:
Traceback (most recent call last):
File "awesome.py", line 2, in <module>
import freenect
ImportError: No module named freenect
libusb: 0.460928 debug [libusb_exit]
libusb: 0.461054 debug [usbi_remove_pollfd] remove fd 6
libusb: 0.461203 debug [usbi_remove_pollfd] remove fd 9
This solved it for me. Note that you need to check if the names of your directories match mine. It depends on the Python versions you have installed:
sudo ln -s /usr/local/lib/python3/dist-packages/freenect.so /usr/local/lib/python3.7/dist-packages/.
That freenect.so was installed by default on Python3, so I've linked to it from Python3.7, which is the default for my system.
You can find where it was installed by:
find /usr/local/lib -iname freenect.so
Hope it helps anybody.
Install:
libfreenect
Try:
sudo python2 libfreenect/wrappers/python/demo_cv_async.py
Install python-freenect and other necessary modules by first :
apt-cache search freenect
And then you can select all libfreenect packages as per your convenience:
for this python code error:
sudo apt-get install python-freenect
This worked for me on Ubuntu 14.04 LTS

Categories