no module cv on jupyter - python

I am working on Jupyter Notebook on my windows. I am trying to import module cv and cv2.
import cv
produces this error.
ImportModuleError: No module cv
Similarly for
import cv2
it produces the error :
ImportModuleError: No module cv
Please help me solve this issue.

To install the opencv-python package without the optional contrib modules into python3:
pip3 install opencv-python --user
To install the opencv-python package with the optional contrib modules into python3:
pip3 install opencv-contrib-python --user
Then to import the module:
import cv2
For both of these installations, their pypi sites state: 'This version does not support video related functionality for MacOS and Linux'.
The Pyimagesearch website by Adrian Rosebrock has a tutorial on how to download and compile opencv for Ubuntu with this functionality.

Related

Problems with cv2 in python

I need to use cv2 library, so I have installed opencv-python library in my conda enviroment: pip install opencv-python.
It said succesfull installation.
Later after doing import cv2 and trying to do x = cv2.imread(), it does not let me use imread, it does not appear in the list:
cv2
I have uninstalled and installed the library but the same happens.
What should i do?

Can't import CV2 in jupyter notebook

I have install cv2 library but I can't import it to my jupyter notebook.
this is how I installed it:
import sys
!conda install --yes --prefix {sys.prefix} opencv
import cv2
>>>
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
I have tried to install libGL but still got that error. Any idea how can I solve this?
Instead of using conda, try using the pip formula, which is specifically built for the Python ecosystem, place this in a separate cell and run it:
!pip install opencv-python
... or if you want to use non-free modules:
!pip install opencv-contrib-python

PyCharm does not find cv2 no matter what I try

I tried to install OpenCV in so many ways. I tried this tutorial:
https://docs.opencv.org/master/d0/db2/tutorial_macos_install.html
I tried using conda:
conda install -c conda-forge opencv
etc. etc.
But when I type in import cv2 it says:
PyCharm Image OpenCV
Does somebody have an idea?
To install opencv you can either build it with CMake (like the link you tagged) or install a pre-built version of it (easier).
You can do the pre-built via PyCharm going to your project settings and adding the 'opencv-python' package or running pip install opencv-python
If you need both main and contrib modules you can install 'opencv-contrib-python' instead
Here's the package's page: https://pypi.org/project/opencv-python/

No module named 'cv2.cv2'

I am a beginner at computers. I use Anaconda python 3.6 in windows 10. I have already installed OpenCV using this command:
pip install opencv-python
But when I try to import cv2 using this:
import cv2
this error shows up:
How can I install openCV for python?
Based on python opencv link: https://pypi.org/project/opencv-python/
Step 1:
Uninstall the opencv first if you have previous/other manually installed (= not installed via pip) version of OpenCV installed (e.g. cv2 module in the root of Python's site-packages)):
pip uninstall opencv-python
Step 2:
Install the package afresh
pip install opencv-python
Hope that works!
try this:
Create Virtual Environment
conda create --name opencv-env python=3.6
Activate the environment
activate opencv-env
Install OpenCV and other important packages
pip install numpy scipy matplotlib scikit-learn jupyter
pip install opencv-contrib-python
pip install dlib
Test your installation
import cv2
cv2.__version__
In my case, using Python 3.8 on Windows 10 and Pycharm (or VS Code as well), I have this same issue.
Finally I noticed that the Antivirus (Nod32) deletes the cv2.cp38-win32.pyd file that should be in the cv2 folder. I simply paused the protection, installed opencv with pip install opencv-python command and it worked just fine.
I hope it helps someone.
This happened to me because I setup a virtual environment with python 32-bit and my modules required the 64-bit version so it seemed there was a version conflict of CV. Changing the python version in my environment fixed the issue.
I was facing a similar issue. In my case, the issue occured because of previous dependencies.
!pip install easyocr
!pip install imutils
if you are running these commands first and then importing
import cv2
from matplotlib import pyplot as plt
import numpy as np
import imutils
import easyocr
then you will get this error. So you first import CV2 and then pip install easyocr or other libraries. This worked in my case.
I used the answer provided here and it worked.
By running pip install opencv_python-3.4.5-cp36-cp36m-win_amd64.whl
I had this exact same problem on Windows 10. Uninstalling via pip and then reinstalling in my virtual environment fixed everything up for me.
Here's a link that helped https://pypi.org/project/opencv-python/
Try reinstalling openCV — it worked for me.
To uninstall:
pip uninstall opencv-python
To reinstall:
pip install opencv-python

importing opencv version 3.4.2.17 in python 3.7

I have already installed opencv in anaconda prompt by entering the command:
pip install opencv-python
it installed properly, but I'm unable to import the module in jupyter notebook.I entered the following command in jupyter:
import opencv
but it's showing ModuleNotFoundError
Also, to resolve anaconda environment issues, I entered the following command in anaconda prompt:
conda install -c conda-forge opencv
this further downloaded and extracted packages:
libopencv-3.4.1,opencv-3.4.1,py-opencv3.4.1
but still I'm unable to import opencv or libopencv module in my Jupyter notebook.
What should I do to use opencv3.4.2.17 in my python version3.7?
The correct syntax for importing opencv is as follows:
import cv2
If opencv was correctly installed, it should work.
For installation of OpenCV, use:
pip install opencv
To import OpenCV, use:
import cv2

Categories