15

I am trying to import cv2 module in PyCharm, but it shows error. I tried in terminal as well

pip install opencv-python pip3 install cv2 pip install opencv-python pip3 install cv2 

and whatnot.

Trying to install opencv-python from terminal shows this

Requirement already satisfied: opencv-python in ./anaconda3/lib/python3.6/site-packages (3.4.1.15) 

and trying to install cv2 from terminal shows this

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

However, trying to import cv2 on Pycharm shows this :

Pycharm Error Image

8
  • pycharm want to install opencv-python like pip install cv2, but he need to install it like pip install opencv-python Commented Jun 30, 2018 at 12:18
  • You use a mix of pip-pip3 on anaconda python. Why not something one? Why not conda install cv2 ? Commented Jun 30, 2018 at 12:18
  • it shows PackagesNotFoundError @Ingaz Commented Jun 30, 2018 at 12:20
  • Have you tried instructions from anaconda.org/conda-forge/opencv? Commented Jun 30, 2018 at 12:24
  • I propose that you forget about pycharm for some time and create working python environment. Do you really need anaconda from start? Commented Jun 30, 2018 at 12:26

5 Answers 5

29

First, install the package named opencv-python via pip install opencv-python or use the GUI.

Second, just input import cv2; that is ok.

Sign up to request clarification or add additional context in comments.

1 Comment

Adding to this, if you can't install via the terminal, try doing it by going into the Intepreter settings. For me, turns out the version of opencv I was trying to download just wouldn't! Downloaded an older version in the end
11

Go to File->Settings->Project Interpreter and then add by '+' button 'opencv-python' module on this repository.

It downloaded without an error for my PyCharm and also downloaded the dependencies as well.

1 Comment

For those having similar issues as the OP and have already tried the pip install opencv-python without success, this may be your correct answer. Go to the Interpreter, press the "+" button, search for "opencv-python", click "Install Package." After that, import cv2 should work
0

While creating a new project in PyCharm, please select 'Base Interpreter' option from drop-down similar to the one shown in this link: Creating new Project stage

Next, after successful creation of project and after downloading the opencv-python, it looks a shown in this link: Success message

Comments

0

In my case, I tired several solutions from internet.No luck. But below approach worked fine with me.

In the pycharm interpreter settings, I installed pip & opencv-python. This worked.

Comments

0

I also had the same problem, maybe you should after doing all the above, just continue your code and it will work. it did for me

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.