ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so in Jetpack 3.2 (keras with pip3)

In Jetson TX2, Jetpack 3.2, I installed keras with pip3. I have python 3 and 2.

In my code, I received the error.

  4 import numpy as np
  5 # opencv
 > 6 import cv2
  8 import matplotlib.pylab as plt

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

How can I correct it without corrupting ROS?

Could you describe more about your request? What did you install?

Are you trying to create a ros package with Keras support? If so:
ROS (ROS-1) does not officially support Python 3. You can try build ROS separately with Python 3, but there’s no guarantee this would work if you need a lot of unique packages/libraries.

If you’re trying to just run an independent python script and it’s linking to python2.7, a simple test would be to run “python3 your_code.py” and see if that works. It appears as though you have multiple versions of python in your system and the default is 2.7.