ModuleNotFoundError: Exercise 3.3 creating custom messages

While following exercise 3.3 on creating custom messages I ran into a ModuleNotFoundError on launching the publisher.

Blockquote
File “/home/user/catkin_ws/src/exercise_33/scripts/publish_age.py”, line 4, in
from exercise_33.msg import Age import Age message from the exercise_33 package
ModuleNotFoundError: No module named ‘exercise_33’

Following on the suggestions given in the many forum posts on this issue did not lead to a solution.

What eventually worked for me was removing the below line in packages.xml and making the package again ie catkin_make and source.

<build_export_depend>message_runtime</build_export_depend>

ROS.org tutorial on the custom messages does not include build_export_depend.

Hopefully this helps you if you get stuck as I did.

I don’t think this was the problem. Otherwise, you should have encountered this problem while compiling, and other students would have reported it.

When you get this error, it indicates that your package was not properly compiled and/or sourced. You can fix this problem by

  1. Recompiling the whole workspace and
  2. Sourcing ~/catkin_ws/devel/setup.bash on every terminal where you want to run the program or use the custom message.
    • Please note the emphasis on “on every terminal”. There’s a tendency to only source on the terminal where use ran catkin_make, but you must source every terminal you wish to use.
cd ~/catkin_ws
rm -rf build/ devel/
catkin_make

# Run this on this terminal and other terminals you wish to use
source devel/setup.bash
``

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.