ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I'm not sure that there is any well supported way to do this, but if you really really need to hack it you could probably modify sys.path at the top of your python script.

When you do ". /opt/ros/hydro/setup.bash" the PYTHONPATH environment variable gets set to "PYTHONPATH=/opt/ros/hydro/lib/python2.7/dist-packages". The opencv python module is there, in "/opt/ros/hydro/lib/python2.7/dist-packages/cv.py".

When your python script starts, it sets up its module search path (sys.path) using the PYTHONPATH environment variable. You can modify this and it will change where python looks for modules:


#!/usr/bin/env python                                                                                                                                            
import sys                                                                                                                                                       
sys.path = ['/path/to/your/opencv'] + sys.path                                                                                                                   
print sys.path                                                                                                                                                   
# do stuff.... 

This will cause python to see your installed opencv3.0 before the opencv that got installed by ROS. This is a pretty big hack though, so it might not go completely smoothly.