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 image130s ( 2019-07-26 03:26:21 -0500 )edit

thank you for the heads up.

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

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

Seen: 45 times

Last updated: Jul 20