5

I am trying to use OpenCV for Python 3 for the first time. To install, I simply typed "pip3 install opencv-python" into the terminal. When I do this, I see in Finder (I'm on a Mac), that in /usr/local/lib/python3.7/site-packages, I now have a new folder called "cv2". This is strange. Why isn't it cv3, as I used pip3? I do not know.

When I try to import cv2 from python3, it says "No module named 'cv2'". Luckily StackOverflow already has a solution: if I first change directories like: "cd /usr/local/lib/python3.7/site-packages" then I will be able to open cv2. I do not know why this step is necessary for OpenCV. I don't have to do this to "import numpy" for example; "numpy" does not care what directory I start from, and it is listed like just another module like cv2.

Anyways, I change directory to site-packages, start python3, and I import cv2. Now there is a new error. This time cv2 is found, but it says:

"from .cv2 import *
ModuleNotFoundError: No module named 'cv2.cv2'"

For the record, I also have Python 2.7. If I try "cd /usr/local/lib/python2.7/site-packages" and then start Python 2.7, I can import cv2. This is ok, but I want to use OpenCV with Python3.

Let me summarize.

(1) How can I get cv2 or cv3 to import when I start from any directory? Is this ever possible?

(2) How can I get cv3 for python3? cv2 seems to be problematic in python3 because because there is no "cv2.cv2"

2 Answers2

0

The only thing we need to know here is, that 2 in cv2 is not a version. cv2 uses API of C++ while cv uses C API. Version of it is constantly updating being inside CV2.

-1

There is no cv3 there's only import cv2 that opencv older or latest that is updated for old python or latest.

Ram
  • 1
  • 1