Ask Your Question

OpenCV doesn't work with two python versions

asked 2019-08-08 17:04:18 -0600

The version of python installed on Ubuntu (16.04.3) was python2. I installed python3. I now install the opencv library on python3, the result is:

import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 'cv2'

But, it is OK in python2.

import cv2

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-08-09 14:26:57 -0600

holger gravatar image

Haha :-) Well that's the python madness of installing dependencies per python installation - globally-. Just reinstall with pip for your other version too - maybe consider using virtualenv.

edit flag offensive delete link more


Do you mean reinstall pip3 and install cv2 on virtualenv? Sorry, but I'm beginner for python. Thanks a lot for the help.

hel.turon gravatar imagehel.turon ( 2019-08-09 15:21:10 -0600 )edit

Look pls- just stay calm and use your head. What i t tried to tell you is to just reinstall opencv for the version where it is missing(basic common sense?). With virtualenv you can switch between different python versions.

holger gravatar imageholger ( 2019-08-09 15:33:22 -0600 )edit

Question Tools

1 follower


Asked: 2019-08-08 17:04:18 -0600

Seen: 277 times

Last updated: Aug 09 '19