catkin_make fails Import error: no module named error for yaml library

asked 2019-10-21 14:32:35 -0600

panda_robo_gal gravatar image

updated 2019-10-21 14:36:52 -0600

gvdhoorn gravatar image

Trying to write a subscriber node using genpy module.

The build fails:

Traceback (most recent call last):
  File "/opt/ros/kinetic/share/genpy/cmake/../../../lib/genpy/", line 44, in <module>
    import genpy.generator
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/genpy/", line 34, in <module>
    from . message import Message, SerializationError, DeserializationError, MessageException, struct_I
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/genpy/", line 44, in <module>
    import yaml
  File "/usr/lib/python2.7/dist-packages/yaml/", line 2, in <module>
    from error import *
ImportError: No module named 'error'
edit retag flag offensive close merge delete



Do you have an alternative Python intepreter installed / active? Such as Anaconda, or have Python 3 as you're default interpreter?

The ROS Python packages (for Kinetic at least) are only built for the standard, system-provided Python 2.7.x interpreter, nothing more. So alternative interpreters will not see those packages, neither their dependencies, leading to these kinds of errors.

See aso #q314971 for a similar case.

gvdhoorn gravatar image gvdhoorn  ( 2019-10-21 14:38:27 -0600 )edit