How "ImportError: No module named rospkg" happens
This error is apparently FAQ on answers.ros.org . How does this even happen?
Traceback (most recent call last):
File "/opt/ros/kinetic/share/xacro/xacro.py", line 55, in <module>
import xacro
File "/opt/ros/kinetic/lib/python2.7/dist-packages/xacro/__init__.py", line 42, in <module>
from roslaunch import substitution_args
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch/__init__.py", line 48, in <module>
import rospkg
ImportError: No module named rospkg
For those who seek immediate fix to this issue, you can install by either apt
or pip
as in this answer (although pip
is not a first recommendation in ROS).
But that is only a workaround. rospkg
is depended on by many packages as in the following example output, so I'm worried if there's anything we're missing. In a lot of cases users get this error while running roslaunch
, which directly run_depend
on it. So apparently if you didn't fulfill dependencies by like rosdep
it wouldn't get installed, but then a lot of other packages wouldn't either so I don't even know how you could finish build.
$ docker images | grep -i kinetic-ros-core
ros kinetic-ros-core 36be7bf1f0b9 3 weeks ago 926MB
$ docker run -it ros:kinetic-ros-core
root@57df7176d6bd:/# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
root@57df7176d6bd:/# apt-cache rdepends python-rospkg
python-rospkg
Reverse Depends:
python-rospkg-modules
ros-kinetic-rosgraph
ros-kinetic-rosclean
ros-kinetic-roslib
python-rosdep
ros-kinetic-roscreate
python-rospkg-modules
ros-kinetic-roslaunch
ros-kinetic-rosbag
ros-kinetic-roswtf
ros-kinetic-rospy
ros-kinetic-rosmsg
ros-kinetic-rosmake
ros-kinetic-rosunit
root@57df7176d6bd:/# apt-cache policy ros-kinetic-rosgraph
ros-kinetic-rosgraph:
Installed: 1.12.12-0xenial-20171116-185949-0800
Candidate: 1.12.12-0xenial-20171116-185949-0800
Version table:
*** 1.12.12-0xenial-20171116-185949-0800 100
100 /var/lib/dpkg/status
The referenced question doesn't exist. And "blindly" recommending
pip
is not a good idea.Anaconda installation raises this problem any solution?