Search code examples
pythonopencvrosdji-sdk

import cv2 error affected by ROS kinetic cv2 installation


I encountered this error when attempting to run a python3 script with the line import cv2. Seems like it is affected by my ROS kinetic installation

    import cv2
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type

Solution

  • Found a simple workaround. Add this line to the top of the code

    import sys 
    sys.path.remove('/opt/ros/kinetic/lib/python2.7/dist-packages')