Python 3.5 ImportError: dynamic module does not define module export function (PyInit_cv2)
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.
Carlos Henrique
Updated on July 09, 2022Comments
-
Carlos Henrique almost 2 years
This is what I'm getting when i try to import cv2 into python3.5 IDLE. I'm using OpenCV 3.1.0 Python3.5.2 Ubuntu 16.04
I tried lots of installing methods but no one solved my problem, i had the import working on terminal but it just stopped as well. Anyone might have a solution?
import cv2 Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> import cv2 ImportError: dynamic module does not define module export function (PyInit_cv2)
Edit: I followed the tutorials on this links:
http://docs.opencv.org/3.0-last-rst/doc/tutorials/introduction/linux_install/linux_install.html
http://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/
-
Carlos Henrique over 7 yearsThank you for the answer, it solved the problem in the terminal, but i still have it in the IDLE