0

Previously ROS was installed in my system which requires opencv for its implementation and now I am using anaconda in which I need to use the opencv library once again. While writing python code import cv2 throws an error module not found.

Is there any way to use that opencv library which ROS installed in anaconda

Although I installed opencv once again using conda.

$conda install -c conda-forge opencv 

however opencv-3.3 was installed using above command. Now my python code is showing different import error as shown below:

ImportError                               Traceback (most recent call last)
<ipython-input-9-6b49ad4d4ca5> in <module>()
      1 from random import shuffle
      2 import glob
----> 3 import cv2
      4 shuffle_data = True  # shuffle the addresses before saving
      5 hdf5_path = 'dataset.hdf5'  # address to where you want to save the hdf5 file

ImportError: /home/kamal/ros_catkin_ws/install_isolated/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type

How can I particularly specify which opencv library to use. What env variables I need to change. Any help will be appreciated.

Kamal Pandey
  • 182
  • 1
  • 1
  • 14
  • Possible duplicate of [After install ROS Kinetic, cannot import OpenCV](https://stackoverflow.com/questions/43019951/after-install-ros-kinetic-cannot-import-opencv) – GPPK Apr 26 '18 at 15:45

1 Answers1

0

uncommenting the line source /home/user/ros_catkin_ws/install_isolated/share/setup.bash in the .bashrc file dosen't help. You also need to remove the extrasys.path added by the ROS environment. In a python console

import sys
print (sys.path)

you will see multiple paths related to ROS then remove the unwanted part of the path by

sys.path.remove('unwanted_path')

This will solve the problem but now ROS will not work. To make it work you need to append the removed path again. If someone has a better approach please answer.

Kamal Pandey
  • 182
  • 1
  • 1
  • 14