2

I am getting error while installing OpenCV package from project interpreter.

Error occurred: Non zero exit code(1)

When I execute command, pip install cv2 ..it gives error as,

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

Please help me solve this error.

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
Ayyswariyaa
  • 67
  • 1
  • 6
  • 13

3 Answers3

8

The package name is actually opencv-python. So you should do:

pip install opencv-python

However, the package is only available on pypi for version 3, not for version 2. I think the misunderstanding could come from when you are actually importing the package you do:

import cv2

But that is actually not the package name on pypi. See the documentation on pypi for more details.

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
yanxun
  • 566
  • 2
  • 10
  • I am getting this error when I try to run the command pip install opencv-python. Could not find a version that satisfies the requirement opencv-python(from versions: )No matching distribution found for opencv-python – Ayyswariyaa Nov 21 '17 at 05:37
  • Hmm, that's weird, because I am successful in downloading it. If you are using PyCharm, have you tried searching and downloading from Pycharm's Project Interpreter interface? – yanxun Nov 21 '17 at 08:09
  • It says run from system terminal.Make sure that you use the correct version of pip installed for your python interpreter located at /usr/bin/python3.5 – Ayyswariyaa Nov 21 '17 at 09:19
  • try updating your pip, `pip install --upgrade pip` – yanxun Nov 21 '17 at 10:25
  • I tried everything..It gives the same error for most of the packages – Ayyswariyaa Nov 21 '17 at 10:32
  • Maybe your pip was installed for the wrong python? Try this https://stackoverflow.com/questions/25607837/pip-install-not-installing-into-correct-directory – yanxun Nov 21 '17 at 11:38
  • I gave export $PATH=/usr/bin/python3.5:$[PATH].. It says not a valid Identifier – Ayyswariyaa Nov 21 '17 at 13:41
  • try `export PATH=/usr/bin/python3.5:$[PATH]` – yanxun Nov 21 '17 at 16:05
  • yup, it doesn't show any output because it is adding a new path into your $PATH variable, now try `echo $PATH` to see if your Python path is added into $PATH. – yanxun Nov 22 '17 at 10:15
  • Oh ok..let me try. – Ayyswariyaa Nov 22 '17 at 10:23
2

In pycharm go to :

  1. File
  2. Settings
  3. Expand Project : [your project name]
  4. Select "project Interpreter"
  5. In the top right corner of the grid listing the packages, click the green plus button A popup "Available packages" will appear

    enter image description here

  6. If no package is available in the list in the left, click the "Manage repositories" button, add this package URL (https://pypi.python.org/simple), then restart pycharm (You may also need to update pycharm to the lastest version, there was a bug here)

  7. In the search box type "opencv-python"

  8. Select the "opencv-python" package in the list and click the "Install Package" button in the bottom left of the popup

  9. Now go back to your code, it will no longer comply about the missing cv2
ihebiheb
  • 3,673
  • 3
  • 46
  • 55
1

Easy Way to go .. You can follow these steps:

  1. Open Settings in Pycharm.
  2. In Settings, on left there will be an option of Project: Your Project Name.
  3. Press it and then inside it click Project Interpreter.
  4. Now there will be a plus sign over right frame.
  5. Press that sign and write opencv-python and then install the package.

write import cv2 in your program to use it.

Bilal Nadeem
  • 19
  • 1
  • 5