ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Cannot import my self-defined msg in ROS using Python

asked 2019-10-15 06:26:28 -0600

drodgu gravatar image

Hi everyone,

I'm quite new in programming using Python, but I need to use it in order to call some libraries in ROS I've downloaded from Github. The thing is that I need to call a msg I've created (it works in ROS using C++), but when I try to load it in a Python script using from my_pkg.msg import my_msg it just exit because of the following error:

ImportError: No module named msg

I've followed the instruction you can find in this tutorial 1 and I've read a lot of topics, but I still cannot solve it. The thing is that for what I can understand from other topics and user answer, Python makes itself a mess and cannot find the module. There's something I might be forgeting. Any idea?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-10-15 06:47:48 -0600

pavel92 gravatar image

updated 2019-10-15 06:51:41 -0600

I guess your custom messages are in the package named my_pkg. Add that package in your package.xml so the messages are built before this package is to be used:


If you have already done so, you can also check this question.

edit flag offensive delete link more


I'm sorry I answer you so late. I've tried but failed. The compiler says that you cannot load that package on my_pkg or something like that. Finally I've decided to create a new package with al my messages and use that package messages instead.

Thank you very much for your quick answer!

drodgu gravatar image drodgu  ( 2019-10-15 12:50:30 -0600 )edit

Question Tools



Asked: 2019-10-15 06:26:28 -0600

Seen: 1,036 times

Last updated: Oct 15 '19