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

Module not found error with rospkg when trying to import roslib

asked 2019-07-17 07:49:16 -0500

microbot gravatar image

Hello,

I have developed a custom control algorithm for mz robot in gazebo. Untile yesterday I used to use

roslaunch spider_gazebo spider_world.launch

to spawn the robot and load control configurations in gazebo and then in another terminal i used to export ROS_MASTER_URI and then use

rosrun spider_control control.py

to run my custom python plugin. Until yesterday this was working well, but today when I tried to launch again `I am having the following error

    'Traceback (most recent call last):
   File "/home/microbot/catkin_ws/src/spider/spider_control/control.py", line 5, in <module>
     import roslib
   File "/opt/ros/melodic/lib/python2.7/dist-packages/roslib/__init__.py", line 50, in <module>
     from roslib.launcher import load_manifest
    File "/opt/ros/melodic/lib/python2.7/dist-packages/roslib/launcher.py", line 42, in <module>
      import rospkg
    ModuleNotFoundError: No module named 'rospkg'

I have also tried the following command to check whether my python path is right or not ,

 'echo $PYTHONPATH'

The output is

  '/home/microbot/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist- 
    packages:/opt/ros/melodic/share/ros/core/roslib/src

I can not understand whats causing this error. can any one please help me point out the reason. Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-07-20 15:56:02 -0500

microbot gravatar image

I believe I have found the answer. The python-rospkg i have instaled are from python 2.7 version. Every time I install them, they get installed directly in /usr/lib/python2.7/distro-package path. But my terminal is sourcing only my work space and ros path. Also the plugin I am trying to run is built with python3. Since the python-rospkg I have installed are for python2.7, I am having this error

The second error with tensorflow is because , I have installed tensorflow for python3 and when I manually set the python path to python2.7/distro-package, it can not find tensor flow and hence this enum error.

PS: careful when trying to install python3-rospkg, when performing binary instalation, it is automatically removing plenty of ros related python2.7 packages. Unfortunately major commands in ros like roslaunch, rosrun etc still use python2.7

edit flag offensive delete link more

Comments

https://answers.ros.org/question/2376... might be the best thread regarding Python 2 & 3 issues for ROS1, fyi.

130s gravatar image 130s  ( 2019-07-26 03:26:21 -0500 )edit

thank you for the heads up.

microbot gravatar image microbot  ( 2019-07-28 12:59:29 -0500 )edit

@microbot were you able to fix the issue? I'm facing the exact same problem. I would be thankful if you could guide me.

polykb gravatar image polykb  ( 2021-04-22 03:30:14 -0500 )edit

@polykb Please open a new thread, and refer to this thread. Person who posted a question or answered won't necessarilly come back to this thread so chance for you to get responses is slim if you ask a question in the comment section. Also condition of each question can be more or less different.

130s gravatar image 130s  ( 2021-04-22 14:20:40 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2019-07-17 07:49:16 -0500

Seen: 3,774 times

Last updated: Jul 20 '19