Exercise 4.3 ROS Basics Python

The link mentioned above got into the same problem as yours. so from the articles try the following:

Go to the catkin_ws directory and run commands:
rm -rf build/ devel/
Now compile as shown.

After compilation, try running the program again to check if problem persist.