Python 3.5 ImportError: dynamic module does not define module export function (PyInit_cv2)

22,428

I had this problem after I installed other versions of OpenCV (for various reasons, one of them installing ROS, which has its own OpenCV version). It seems this caused a conflict. To make sure that PyOpenCV gets loaded correctly enter an interactive session and check:

import sys
print(sys.path)

You can try that inside IDLE as well.

The path to cv2.cpython-35m-x86_64-linux-gnu.so should appear there. If it doesn't, insert it to path:

sys.path.insert(1, '<path to .../dist-packages with cpython so>')

Make sure it goes before any other option which may be causing conflict. Then try again:

import cv2

It should work now and that would mean the problem was the python path. It may also help to figure out what is causing conflict in your case and how is best to solve it for you.

Share:
22,428
Carlos Henrique
Author by

Carlos Henrique

Updated on July 09, 2022

Comments