Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm/Python OpenCV and CV2 install error

I've been trying to install both OpenCV and cv2 from both Pycharm and from the terminal as suggested using:

pip install --user opencv pip install --user cv2 

but I'm getting the following error for them:

Collecting opencv   Could not find a version that satisfies the requirement opencv (from versions: ) No matching distribution found for opencv 

and

Collecting cv2   Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2 

How can I fix these and install the packages properly? I'm using python 3.4.

like image 296
Sibi Avatar asked Jun 12 '16 15:06

Sibi


People also ask

How do I fix import cv2 error?

The Python "ModuleNotFoundError: No module named 'cv2'" occurs when we forget to install the opencv-python module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install opencv-python command.

Is OpenCV-Python and cv2 same?

cv2 is the module import name for opencv-python, "Unofficial pre-built CPU-only OpenCV packages for Python". The traditional OpenCV has many complicated steps involving building the module from scratch, which is unnecessary. I would recommend remaining with the opencv-python library.

Can you use OpenCV in PyCharm?

Steps to import OpenCV on PyCharm: 1) Go to the terminal option at the bottom of the IDE window. 2) The pip (package manager) can also be used to download and install OpenCV. To install OpenCV, just type the following command: Python3.


2 Answers

You are getting those errors because opencv and cv2 are not the python package names.

These are both included as part of the opencv-python package available to install from pip.

If you are using python 2 you can install with pip:

 pip install opencv-python 

Or use the equivilent for python 3:

pip3 install opencv-python 

After running the appropriate pip command your package should be available to use from python.

like image 148
Ryan Guest Avatar answered Oct 03 '22 20:10

Ryan Guest


This the correct command that you need to install opencv

pip install opencv-python 

if you get any error when you are trying to install the "opencv-python" package in pycharm, make sure that you have added your python path to 'System Variables' section of Environment variables in Windows. And also check whether you have configured a valid interpreter for your project

like image 43
Sankha Rathnayake Avatar answered Oct 03 '22 20:10

Sankha Rathnayake