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

ImportError: No module named rospkg

asked 2018-09-10 11:02:22 -0500

dovulthesloth gravatar image


I use Ubuntu 16.04 LTS, ROS Kinetic, and Anaconda. Python 3.6 is my default python. Now I'm following ROS Tutorials, particularly this part: .

So I wanna run this command:

$ rosrun rqt_graph rqt_graph

But I get this Error messages all the time,

rosrun rqt_graph rqt_graph
Traceback (most recent call last):
  File "/opt/ros/kinetic/lib/rqt_graph/rqt_graph", line 5, in <module>
    from rqt_gui.main import Main
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_gui/", line 38, in <module>
    import rospy
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/", line 49, in <module>
    from .client import spin, myargv, init_node, \
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/", line 52, in <module>
    import roslib
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslib/", line 50, in <module>
    from roslib.launcher import load_manifest
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslib/", line 42, in <module>
    import rospkg
ModuleNotFoundError: No module named 'rospkg'

I've already installed ROS Packages with:

 sudo apt-get install python-rospkg

And I get the same problem in venv as well. Thank you in advance for your answers. :)

edit retag flag offensive close merge delete



The problem is probably due to Anaconda which requires you to modify your path. Search around on the site and you'll find many people with similar problems.

jayess gravatar image jayess  ( 2018-09-10 11:31:52 -0500 )edit

Yeah I found some similar problems, I think I'll just unistall anaconda then. It is the simplest solution.

dovulthesloth gravatar image dovulthesloth  ( 2018-09-10 11:35:19 -0500 )edit

I don't think that you have to uninstall Anaconda. You can probably just remove the line from your .bashrc file that adds Anaconda to your path. If you want to use Anaconda you can add it to your path manually. Keep in mind that I don't use Anaconda though.

jayess gravatar image jayess  ( 2018-09-10 16:15:52 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-09-10 18:40:51 -0500

Geoff gravatar image

Following up the comments by @jayess, you can remove the references to Anaconda from your .bashrc file (or any other startup files you have them in. You don't need to uninstall Anaconda. Removing the references to it in your startup files disables it, giving you the option of enabling it manually as needed.

Adding a function to your .bashrc file to enable Anaconda is a good way to make it easy to enable on an as-needed basis. (This works for anything else that goes in the .bashrc file as well, like ROS if you want to be able to switch distributions quickly.)

edit flag offensive delete link more

Question Tools



Asked: 2018-09-10 11:02:22 -0500

Seen: 2,472 times

Last updated: Sep 10 '18