Exercise 4.3 ROS Basics Python

Hi @maanvisingh,

I created a package and created a message named Age.msg just like you did to reproduce the error you are experiencing.

I then created a file named age_pub.py and put the content you shared here and it failed for the same reason.

I then tried to fiind a file named Age.py in my ~/catkin_ws (which should have been generated when we run catkin_make) but could not find it, which left me thinking :thinking:.

I then checked the ~/catkin_ws/devel/lib/python3/dist-packages/my_examples_pkg/msg/ folder, and for my surprise, I found that the generated file was named “_Age.py” instead of “Age.py”. I have no idea why this happened.

But to solve the issue, I just copied the _Age.py file to Age.py

 
cp -v ~/catkin_ws/devel/lib/python3/dist-packages/my_examples_pkg/msg/_Age.py ~/catkin_ws/devel/lib/python3/dist-packages/my_examples_pkg/msg/Age.py

After that, running python age_pub.py worked.

Again, I don’t know why the generated file was named _Age.py instead of Age.py, but copying it to Age.py solved the problem in my tests.