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.
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
Recompiling the whole workspace and
Sourcing ~/catkin_ws/devel/setup.bashon 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
``