how to solve import error no module name cv in python? - opencv

i am running the python code but every time is showing
line 13,in
import cv2.cv as cv2
importerror: No module named cv
how to slove this problem,
i am using rPi 2 opencv-3.1.0 with python 2.7

If you have compiled opencv from source, link cv2.so from compiled directory to your python system directory (generally it is /usr/local/lib/python2.7/dist-packages/)
If not helpful, setup venv in your project directory and link cv2.so and cv.py from python system directory to your project directory.

Related

Cannot import opencv after succesfull install on Raspberry Pi

I try to install opencv on my Raspberry Pi with 4GB RAM (Raspberry OS version Linux 5.15.84-v8+ aarch64). Instructions I found on q-engineering. After a 2hr lasting build process the make announced that opencv was succesfully installed. When I try to import it I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
But opencv appears to be succesfully installed. When I run opencv_version I got:
$ opencv_version
4.7.0-dev
and:
/usr/local/bin/opencv_visualisation
/usr/local/bin/opencv_annotation
/usr/local/bin/opencv_version
/usr/local/bin/opencv_model_diagnostics
/usr/local/bin/opencv_waldboost_detector
/usr/local/bin/opencv_interactive-calibration
/usr/local/share/licenses/opencv4
/usr/local/share/opencv4
/usr/local/lib/aarch64-linux-gnu/cmake/opencv4
/usr/local/lib/aarch64-linux-gnu/pkgconfig/opencv4.pc
/usr/local/include/opencv4
/usr/local/include/opencv4/opencv2
/usr/local/include/opencv4/opencv2/opencv.hpp
/usr/local/include/opencv4/opencv2/gapi/opencv_includes.hpp
/usr/local/include/opencv4/opencv2/opencv_modules.hpp
Looking for cv2 or *cv2* yielded nothing except what was already listed above. The date/time of the files conform to the time I ran the install script.
Next I tried opencv-lite according to instructions from the same source. Same result: succesful installation, traces of newly put opencv files but import cv2 still fails.
To complicate matters I use anaconda environments. I got two: base and rpi. I installed with rpi activated. In both no trace of opencv or cv2 and in both cases import fails. Some information where the system fetches python:
$ which python
/home/arnold/bin/anaconda/envs/rpi/bin/python
(rpi) arnold#bottie:~/bin/opencv/opencv/build
There is python in /bin/python and /usr/bin/python I found out with vscode. I tried both and both failed.
My questions:
did installation of opencv really succeed?
if so, is it possible to 'connect' the installation to a running version of python, preferably a conda environment?
if not, what is the best way to proceed?
I try this links. install OpenCV 4 for RPI 4 It worked for me using RPi 4B/8GB 64-bit.
Do update first
Install OpenCV
Check getBuildInformation()
After that if not getting . Then install sudo apt
pyhton3-opencv-contrib
No needed to do cmake. And you ready to go.

Cannot find reference 'ximgproc' in '__init__.py

i want to use cv2.ximgproc module.
this is add-on module at Opencv
but there is a problem to load module.
I tried pip install opencv-contrib-python but it doesn't work.
to be precise its already installed but can't not find cv2.ximgproc module.
import cv2
...
cv2.ximgproc.thinning( ... )
that's my import section.
So, I tried paste source file from OpenCV github
but there is only C++ source..
( sometimes .py file exist. but that is not file I need. )
It is just PyCharm Error.
PyCharm represents 'Can't find'.
but I Run my code, and its works well..

conda install opencv ImportError: the specified module could not be found

I installed opencv using the conda command:
conda install -c conda-forge opencv
The installation was successful without errors. Typing conda list also indicates opencv installed. But import cv2 gives the error: DLL load failed: The specified module could not be found.
I note the opencv does not show up in the Lib/site-packages folder, but occurs in the pkgs folder, that is, C:\\Anaconda\\Anaconda3.7\\pkgs\\opencv-4.1.1-py37h6afde12_1. The site-packages folder has a file cv2.cp37-win_amd64.pyd;
What is problem with the import cv2 error? Was the conda-based opencv installation really successful? My python version is python3.7.1.
A similar problem has been reported here DLL load failed error when importing cv2
Try to install with pip. 'pip install opencv-python'
Did you install the contribution packages of opencv?

OpenCV issue: ModuleNotFoundError: No module named 'cv2' on a Mac

I know I have OpenCV installed, the path is here: cd /anaconda3/lib/python3.7/site-packages/cv2 The python interpreter allows me to run import cv2 successfully with no error, yet when I run import cv2 in Sublime text editor I get ModuleNotFoundError: No module named 'cv2'
import cv2, sys, pytesseract
Python 3 in Sublime text editor searches in the default system locations when it tries to import Python modules, however you have installed OpenCV in a non-default location using Anaconda. Please append the path to cv2 to your system's path variable so that Sublime text editor can find it. To show the PATH in macOS type echo $PATH You haven't specified it in your question, but the path to cv2 is something like /home/autonocat/anaconda3/lib/python3.7/site-packages/ Please check in Finder if this path is correct.
Alternatively install Spyder3 IDE in Anaconda and run the program from there. Spyder3 can do inline plotting.

ModuleNotFoundError: No module named 'autokeras.image_supervised'

Installed AutoKeras and pre-reqs in 3.6 Python environment using Anaconda.
Trying to test AutoKeras in Jupyter, but keep getting this error:
ModuleNotFoundError: No module named 'autokeras.image_supervised'
from autokeras.image.image_supervised import load_image_dataset
works for me (seems they changed files' structure of project)
I'm using autokeras-0.3.5
from autokeras import ImageClassifier
if this problem is arised then there might be a chance that u might have not installed autokeras library in the enironment.... I got the same error in Colab notebook try this code
!pip install autokeras
This might solve your problem.....

Resources