The fastest and cleanest way is to run pip. It's a clean convenient tool for Python packages.
Just run:
pip install opencv-python or C:\Python27\Scripts\pip.exe install opencv-python
The fastest and cleanest way is to run pip. It's a clean convenient tool for Python packages.
Just run:
pip install opencv-python or C:\Python27\Scripts\pip.exe install opencv-python
The easiest way to install OpenCV on Windows is to simply copy the cv2.pyd file into Python's site-packages directory (e.g. C:\python27\Lib\site-packages).
To get the cv2.pyd file, download and extract the latest version of the OpenCV installation executable from http://sourceforge.net/projects/opencvlibrary/files/opencv-win/ and browse the extracted folder to find the file in the relevant build directory (e.g. build\python\x86\2.7).
Issue "ModuleNotFoundError: No module named 'cv2'" although opencv is installed
Import error.Module not found error cv2.No module named cv2.Cant install open cv
Python: No module named 'cv2' when building OpenCV various versions from sources on Win11 - Python - OpenCV
python - No module named 'cv2.cv2' - Stack Overflow
Videos
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__
First do run these commands inside Terminal/CMD:
conda update anaconda-navigator
conda update navigator-updater
Then the issue for the instruction below will be resolved
For windows if you have anaconda installed, you can simply do
pip install opencv-python
or
conda install -c https://conda.binstar.org/menpo opencv
if you are on linux you can do :
pip install opencv-python
or
conda install opencv
Link1 Link2
For python3.5+ check these links : Link3 , Link4
Update:
if you use anaconda, you may simply use this as well (and hence don't need to add menpo channel):
conda install -c conda-forge opencv
This happens when python cannot refer to your default site-packages folder where you have kept the required python files or libraries
Add these lines in the code:
import sys
sys.path.append('/usr/local/lib/python2.7/site-packages')
or before running the python command in bash move to /usr/local/lib/python2.7/site-packages directory. This is a work around if you don't want to add any thing to the code.
In Windows 10 you can install it as
pip install opencv-python
this will allow you to import cv2 module
Faced with the same issue on Windows 10 I downloaded the open cv binary from the Unofficial Windows Binaries for Python Extension Packages.
Search the page for opencv and for and download the correct .whl for your system. Then pip install it. By example, on my system, after opening a cmd window I typed the following.
pip install opencv_python-3.4.1-cp36-cp36m-win_amd64.whl
I then opened python and the following worked
import cv2
print(cv2.__version__)
More info is available in this Mark Jay video.
:D
» pip install opencv-python