ImportError: No module named roslib
I am having a problem running python files. Here are the 1st-3rd lines of the py file:
#!/usr/bin/env python
import roslib; roslib.load_manifest('irobot_mudd')
import rospy
Whenever I run $ sudo python ml.py (ml.py being the python file in question)- as well as any other py file importing roslib, I get the error message:
Traceback (most recent call last):
File "ml.py", line 2, in <module>
import roslib; roslib.load_manifest('irobot_mudd')
ImportError: No module named roslib
If I run
$ python ml.py
I get the following back:
Traceback (most recent call last):
File "ml.py", line 4, in <module>
import cv_bridge
ImportError: No module named cv_bridge
My setup.sh file is as follows:
export ROS_ROOT=/opt/ros/electric/ros
export PATH=${ROS_ROOT}/bin:${PATH}
export PYTHONPATH=${ROS_ROOT}/core/roslib/src:${PYTHONPATH}
export ROS_PACKAGE_PATH=/opt/ros/electric/stacks
if [ ! "$ROS_MASTER_URI" ] ; then export ROS_MASTER_URI=http://localhost:11311 ; fi
this is what my python path looks like:
echo $PYTHONPATH
/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:/opt/ros/electric/ros/core/roslib/src:
Here is the result of ls /opt/ros/electric/ros/core/roslib/src:
package.cpp ros roslib
And the result of ls /opt/ros/electric/ros/core/roslib/src/roslib/*.py is:
/opt/ros/electric/ros/core/roslib/src/roslib/exceptions.py /opt/ros/electric/ros/core/roslib/src/roslib/params.py
/opt/ros/electric/ros/core/roslib/src/roslib/genpy.py /opt/ros/electric/ros/core/roslib/src/roslib/resources.py
/opt/ros/electric/ros/core/roslib/src/roslib/gentools.py /opt/ros/electric/ros/core/roslib/src/roslib/rosenv.py
/opt/ros/electric/ros/core/roslib/src/roslib/__init__.py /opt/ros/electric/ros/core/roslib/src/roslib/roslogging.py
/opt/ros/electric/ros/core/roslib/src/roslib/launcher.py /opt/ros/electric/ros/core/roslib/src/roslib/rospack.py
/opt/ros/electric/ros/core/roslib/src/roslib/manifestlib.py /opt/ros/electric/ros/core/roslib/src/roslib/rostime.py
/opt/ros/electric/ros/core/roslib/src/roslib/manifest.py /opt/ros/electric/ros/core/roslib/src/roslib/scriptutil.py
/opt/ros/electric/ros/core/roslib/src/roslib/message.py /opt/ros/electric/ros/core/roslib/src/roslib/srvs.py
/opt/ros/electric/ros/core/roslib/src/roslib/msgs.py /opt/ros/electric/ros/core/roslib/src/roslib/stack_manifest.py
/opt/ros/electric/ros/core/roslib/src/roslib/names.py /opt/ros/electric/ros/core/roslib/src ...
I have tried sourcing /opt/ros/electric/setup.sh While this command works, I still get the error
Please provide the complete backtrace. Maybe it contains something important.
Backtrace of what exactly?
The python backtrace that shows you the import error. Please always copy-paste the exact error you are getting. See http://www.ros.org/wiki/Support
Sure. Here it is:
Sure. Here it is: >>Traceback (most recent call last): >>File "ros_workspace/irobot_mudd/ml.py", line 2, in <module> >>import roslib; roslib.load_manifest('irobot_mudd') >>ImportError: No module named roslib
Could you please edit your original question and add it? That makes it way easier to read :)
Also, please execute
echo $PYTHONPATH
after you got the error, in the same terminal. Just to be sure your program uses the right path... :)