When I try to import cv2 in IPython , I am getting this error-
ImportError: dynamic module does not define module export function (PyInit_cv2)
In my case, I was using opencv library for python2 in python3.
Check your PYTHONPATH by typing
echo $PYTHONPATH
and see there is correct path for python3.
$ echo $PYTHONPATH
:/usr/local/lib/python3.4/site-packages
I define PYTHONPATH at the end of ~/.bashrc file. Modify it if you are loading python2's library.
After source ~/.bashrc or restart terminal, check PYTHONPATH again
It solves my problem.