Unit 4: Exercise 4.3 - No module named "my_publisher_package"

Hi, I read some topics about this problem but I could not fix it. Please check and help me.

Code scrubbed.


I upload the code again.


This seems to be the problem:

You must source on every shell where you want to run the package.

I see that you did source devel/setup.bash on one shell and tried to run the code on another shell. That would not work.

Try this on the shell where you want to run the program:

cd ~/catkin_ws
source devel/setup.bash
# Now run the rosrun command

Thank you. I did it.
But Could you tell me why it is?
I am a newbie ROS so I thought that I can work with multiple terminals but I work with one ROS package.

1 Like

It’s not really a ROS issue - it is the way Linux and most other terminal-based systems work.

Before you can use some packages on a given terminal, and especially when you make changes to those packages, you need to source the “init” file of those packages (again).

The file you are sourcing, in this case, is /path/to/ros_workspace/devel/setup.bash.

Sometimes for ROS, when you have already compiled a package and then make changes to it, you need to remove the build and devel folders in your workspace, then compile on one terminal and source on every terminal..