I have python 3.8. While working a new project in PyCharm, there was a problem while importing opencv package. I tried multiple solutions but was unable to fix the issue. Here are the screenshots of the same. Screenshot of command prompt
-
2Please edit your question by replacing screenshots with actual text. Not only do links die, but it poses problems for the visually impaired.RamblinRose– RamblinRose2020-04-07 13:33:42 +00:00Commented Apr 7, 2020 at 13:33
-
I don't really know what the problem here is, but it looks like the next thing to try to be to specify to pycharm that you want the version of opencv that you already do have installed.ShapeOfMatter– ShapeOfMatter2020-04-07 13:34:47 +00:00Commented Apr 7, 2020 at 13:34
1 Answer
If you are able to install opencv using the command line as showed in the first screenshot, I suggest you to use the same virtualenv (or python interpreter) in PyCharm.
Basically in PyCharm is possible to configure a python interpreter in order to do not install again each package.
I guess that the best approach is to prepare a virtualenv and to use it in PyCharm.
Anyway, to configure the python interpreter in PyCharm you should click on:
File > Settings > Project > Project Interpreter
Here you should be able to see in the top of the window the current python interpreter. To change it, simply click on the gear icon and then on Show all.
If the right one is not present, click on the plus icon and then search it using the Existing environment option.
Note
Looking at your screenshot, seems that you are not using a virtualenv but the system interpreter. If this is correct, when you have to add the new python interpreter, choose the System Interpreter option on the left of the window.
Once added the correct python interpreter, you should be able to import and use opencv in PyCharm.