OpenCV and cv2 problem in jupyter notebook - opencv

I already installed opencv-python-4.5.3.56 in my Anaconda Prompt(Anaconda3) but when import cv2 or import OpenCV in my JupyterNotebook get this errors:
ModuleNotFoundError: No module named 'cv2'
ModuleNotFoundError: No module named 'OpenCV'
What is my mistake?
I have windows 10 and python3

Try to run :
conda list
This is a list of package installed in your envs. If opencv is missing, try :
conda install -c conda-forge opencv

Related

Import cv2 doesn't work despite having installed OpenCV-python

I am a newbie and have been trying to run a python code that uses cv2. I am using the python 3.6.8 terminal.
Please see below for the first part of the code:
import cv2
import numpy as np
import os
import sys
import tensorflow as tf
from sklearn.model_selection import train_test_split
Although I have installed opencv-python, I get a "Module not found" error message as below:
(base) Dhammas-MacBook-Air:python-code-r dhammaandrivini$ python3 traffic.py
Traceback (most recent call last):
File "traffic.py", line 1, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
I would be most grateful for any help with this, as I really want to finish this project! :)
It is most likely that you have installed the package using pip install opencv-python. This is the correct command but if you have multiple python installations on your device it might lead to issues.
I would suggest you try and use the command python3 -m pip install opencv-python, this command will install opencv for the pip being used by python3, which you seem to be using to run your code.

i installed opencv-python getting import error

import cv2
ImportError Traceback (most recent call
last) in
----> 1 import cv2
~\Anaconda3\lib\site-packages\cv2__init__.py in
3 import sys
4
----> 5 from .cv2 import *
6 from .data import *
7
ImportError: DLL load failed: The specified module could not be found
Looks like you are using Anaconda. If so don't use pip as it can break your environment, use conda.
You can try by
first going to "anaconda-prompt" using windows search and then run the command as below:
conda install -c conda-forge opencv
or any other from https://anaconda.org/conda-forge/opencv.
Maybe you can uninstall and install opencv. This usually happens when you download package at a different file location or the package itself is not installed properly.
I suggest using this:
1.pip install opencv-python
or if you need the full module (cnn, face analysis, shape and etc)
2.pip install opencv-python-contrib

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?

Not able to import en_core_web_sm or Spacy

I am trying to import en_core_web_sm as independent package and also tried through spacy. But I am getting an error in ujson module in both case.
Error :
ModuleNotFoundError: No module named 'srsly.ujson.ujson'
I installed en_core_web_sm through following command
python -m spacy download en_core_web_sm
Going by Spacy documentation it shall work. But it is not. I want to import en_core_web_sm.
srsly listed as a dependency so it should be installed. If it's not installed just install it yourself:
python -m pip install srsly

gudhi python module installed but won't import

After importing the gudhi module like:
$ conda config --add channels conda-forge
$ conda install -c vincentrouvreau gudhi
import gudhi
gives import error. python2.7 is installed. Path variable lists the python path. What others have to be checked?
gudhi packages are only available for Python 3.6 for the moment.
I am working for them to be available on conda-forge, but I still have some compilation issue.
You can install GUDHI Python version by doing :
Install Miniconda (for instance) Python 3.6 x64 from here : https://conda.io/miniconda.html
In a command line :
conda config --add channels conda-forge
conda install -c vincentrouvreau gudhi
python
>>> import gudhi
Then you can try examples from documentation : http://gudhi.gforge.inria.fr/python/latest/
Regards,
Vincent Rouvreau

Resources