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

Fuerte : No module named rospkg

asked 2012-09-27 03:28:54 -0500

updated 2014-01-28 17:13:46 -0500

ngrennan gravatar image

Hi all,

I recently migrated to Fuerte and upon building a ros package that used to build in Electric, it throws the following error in Fuerte:

[rosbuild] Building package

[rosbuild] Error from syntax check of

Traceback (most recent call last):
  File "<string>", line 1, in <module>
File "/opt/ros/fuerte/lib/python2.7/dist-packages/roslib/", line 50, in <module>
 from roslib.launcher import load_manifest
File "/opt/ros/fuerte/lib/python2.7/dist-packages/roslib/", line 42, in <module>
 import rospkg
ImportError: No module named rospkg

CMake Error at /opt/ros/fuerte/share/ros/core/rosbuild/private.cmake:78 (message):
[rosbuild] Syntax check of failed; aborting
Call Stack (most recent call first):
/opt/ros/fuerte/share/ros/core/rosbuild/public.cmake:174 (_rosbuild_check_manifest)
subarchitectures/ (rosbuild_init)

So the main problem is that rospkg is not found. This seems similar to these questions:

  1. Import Error
  2. Import Error 2

The solution there is to install rospkg. I already have it installed.

shanker@lt-pool-213:~$ sudo apt-get install python-rospkg
[sudo] password for shanker: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-rospkg is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

I check my PYTHONPATH and it shows:

shanker@lt-pool-213:~$ echo $PYTHONPATH
  1. The path '/opt/ros/fuerte/share/ros/core/roslib/src' doesn't even exist. roslib exists at : '/opt/ros/fuerte/share/roslib'. But there isn't an src folder there. So I'm not sure if that is the problem.

  2. Alternatively, the problem is probably at /opt/ros/fuerte/lib/python2.7/dist-packages . That directory does not have the file rospkg. It has files roslib, rospy, rosnode, rosmsg etc., but not rospkg. Could that be the problem?

Update: Sep 28, 2012: According to Lorenz's suggestion, I have found that rospkg is in /usr/lib/pymodules/python2.7 . However, the problem persists.

Update: Sep 28, 2012: Upon adding '/usr/lib/pymodules/python2.7' to the pythonpath, the error does resolve. However, I am not removing this question as this is still unexpected behavior.

Thanks in advance for your help :)



edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-09-27 03:38:00 -0500

Lorenz gravatar image

The package python-rospkg installs into /usr/lib/pymodules/python2.7. The directory is normally in the python path, not in the variable PYTHONPATH though. To verify if it's really there, first check if you can find rospkg in /usr/lib/pymodules/python2.7. Then execute python in a terminal and type:

import sys; sys.path

The output is a list of paths python uses for finding packages. Check if /usr/lib/pymodules/python2.7 is really in there.

edit flag offensive delete link more



Thanks for the answer. 'rospkg' is inside /usr/lib/pymodules/python2.7 . And that path is present inside sys.path . It is indeed quite surprising why that error still pops up. Any other ideas?

Shanker gravatar image Shanker  ( 2012-09-27 05:09:26 -0500 )edit

Can you try importing rospkg in the python shell? If that fails we at least have a very simple test case. If not, it's really weird...

Lorenz gravatar image Lorenz  ( 2012-09-27 05:11:29 -0500 )edit

'import rospkg' does not throw any errors in the python shell. Should I add '/usr/lib/pymodules/python2.7' to the pythonpath? Shouldn't that be done automatically?

Shanker gravatar image Shanker  ( 2012-09-27 21:28:54 -0500 )edit

I think it should be in your python path already. The error is really weird. Can you try building a different package?

Lorenz gravatar image Lorenz  ( 2012-09-27 22:49:14 -0500 )edit

You can see the output of the PYTHONPATH in my original post. That is not in my PYTHONPATH. Is it implicitly in the PYTHONPATH? I will try building a different package,

Shanker gravatar image Shanker  ( 2012-09-27 23:14:18 -0500 )edit

This error does occur in every package. I don't have much experience with python, reading up about it. Any help would be welcome :)

Shanker gravatar image Shanker  ( 2012-09-27 23:17:35 -0500 )edit

Upon adding /usr/lib/pymodules/python2.7 to my pythonpath, the error does resolve it. Though, I am not closing the question as it is still unexpected behavior?

Shanker gravatar image Shanker  ( 2012-09-27 23:31:01 -0500 )edit

Yes. I think that is unexpected behavior and I have never seen it before. I don't think you are facing a common problem. I can just guess that for some weird reason, sys.path is different when you are executing rosmake.

Lorenz gravatar image Lorenz  ( 2012-09-27 23:36:01 -0500 )edit

answered 2015-12-10 00:10:59 -0500

ros379 gravatar image

Sometimes the rospkg is not installed in the above path. using the method of follow to find the exactly install path in your computer.

Firstly, use the command "pip install python-rospkg" to install rospkg, and you can also find the install path shown follow.

Secondly, edit your .bashrc, add two row as follows at the end of this file.

PYTHONPATH="${PYTHONPATH}:your rospkg install path"


Thirdly, open a new terminal, try the command as follows:


import rospkg

if show nothing, that means you have solved the problem.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2012-09-27 03:28:54 -0500

Seen: 7,033 times

Last updated: Sep 27 '12