Exercise 2.3 No module named my_package

I am trying to send a message of the custom type called Age. I have a package called my_package with a msg directory which contains Age.msg

running rosmsg show Age gives
[my_package/Age]:
float32 years
float32 months
float32 days

and it even says my_package in front of age.

When I try to run the a publisher node it gives me an error on the following line of my python file
from my_package.msg import Age

This is the error it gives
Traceback (most recent call last):
File “/home/user/catkin_ws/src/my_package/src/agePublisher.py”, line 4, in
from my_package.msg import Age
ImportError: No module named my_package.msg

This is the structure of the my_package folder

launch
msg
src
cmakelist
packageXML

I tried running the code using a message type that was different than Age and it works fine, so it does not seem to be a problem with the launch file.

Any ideas?

Hi @edward.jahoda,
you have to add the appropriate packages and entries to the cmakelist.txt and package.xml and then compile it. Make sure you read the tutorial carefully and follow the instructions :slight_smile:

1 Like