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

ImportError : No module named xxxx.msg

asked 2017-09-27 02:34:16 -0600

pibauer gravatar image

updated 2019-04-04 13:33:23 -0600

jayess gravatar image

Hello everyone. I migrate an installation from one computer to another, switching from Ubuntu 12.04 to 16.04 and from indigo ros to kinetic When I run my installation that has about 30 packages most of the things seem to start well except for a package that fails to make an import I specify that I do not have this error on the computer of the previous configuration, or everything is identical in my programs, except the denomination of indigo and kinetic The error is as follows:

From my_folder_msgs.msg import my_file as My_fileMsg   
ImportError : No module named my_folder_msgs.msg

Of course, my_folder_msgs.msg exists and appears when I call: rosmsg list.

Would anyone have an idea?

edit retag flag offensive close merge delete



Hi, Make sure you got the "#!/usr/bin/env python" line at top of your python file, also make sure that youre customs messages are built. You can check with rosmsgs list | grep your_custom_msgs


Nico__ gravatar image Nico__  ( 2017-09-27 07:59:54 -0600 )edit

Thank you for your message. everything was as you advised

pibauer gravatar image pibauer  ( 2017-09-29 14:28:16 -0600 )edit

2 Answers

Sort by » oldest newest most voted

answered 2017-09-29 13:43:33 -0600

updated 2019-04-04 03:41:08 -0600

Hi @pibauer,

when we use our custom messages, even if they are listed with rosmsg list, they only can be used by our nodes after they be compiled.

I have created a video ( ) that answers exactly this question.

The steps explained in the video are basically the following:

  1. You have to compile your message. For that, you have to touch the package.xml and CMakeLists.txt according to the instructions found on CMakeLists.txt. After prepare the package.xml and CMakeLists.txt, you run catkin_make on your catkin_ws

  2. After the message is compiled, you have to source the setup.bash like: source catkin_ws/devel/setup.bash

  3. Now you can import your messages without any problem.

That is it. If you still have any questions, just ask here or watch the video aforementioned.

edit flag offensive delete link more



your video is super clear. thank you for that clarification

pibauer gravatar image pibauer  ( 2017-09-29 14:29:38 -0600 )edit

You're Welcome.

Great to know that it helped.

If you can, just mark the answer as correct.


Ruben Alves gravatar image Ruben Alves  ( 2017-09-29 14:51:40 -0600 )edit

Thanks this helped me too! Just remember to load a new terminal or resource the setup script after compilation.

navibot gravatar image navibot  ( 2018-03-18 06:33:32 -0600 )edit

answered 2019-04-04 13:32:02 -0600

jayess gravatar image

updated 2019-04-04 13:33:03 -0600

For those that don't like to watch videos and want an answer straightaway (this is taken right from the wiki):

Update your package.xml with:


This will tell the build system about the new message definitions.

Next, modify your CMakeLists.txt file by:

adding the following at the end of find_package()

    # any packages your messages depend on such as std_msgs

export the message runtime dependency

  CATKIN_DEPENDS message_runtime ...

add any message files that you have defined and want to compile


call the generate_messages() function

  # and any other packages your messages depend on

Now, navigate to your workspace's root and compile using either

~/catkin_ws/$ catkin_make


~/catkin_ws/$ catkin build

and source your workspace

~/catkin_ws/$ source devel/setup.bash
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-09-27 02:34:16 -0600

Seen: 20,811 times

Last updated: Jun 10 '20