Ask Your Question
0

ImportError : No module named xxxx.msg

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

pibauer gravatar image

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

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

Comments

1

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

Nicolas

Nico__ gravatar imageNico__ ( 2017-09-27 07:59:54 -0500 )edit

Thank you for your message. everything was as you advised

pibauer gravatar imagepibauer ( 2017-09-29 14:28:16 -0500 )edit

2 Answers

Sort by » oldest newest most voted
1

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

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

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 ( https://youtu.be/NKeebwRNvv8 ) 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

Comments

1

your video is super clear. thank you for that clarification

pibauer gravatar imagepibauer ( 2017-09-29 14:29:38 -0500 )edit

You're Welcome.

Great to know that it helped.

If you can, just mark the answer as correct.

Cheers.

Ruben Alves gravatar imageRuben Alves ( 2017-09-29 14:51:40 -0500 )edit

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

navibot gravatar imagenavibot ( 2018-03-18 06:33:32 -0500 )edit
1

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

jayess gravatar image

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

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:

<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>

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()

find_package(
    ...
    # any packages your messages depend on such as std_msgs
    message_generation
)

export the message runtime dependency

catkin_package(
  ...
  CATKIN_DEPENDS message_runtime ...
  ...)

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

add_message_files(
  FILES
  my_file.msg
)

call the generate_messages() function

generate_messages(
  DEPENDENCIES
  std_msgs
  # and any other packages your messages depend on
)

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

~/catkin_ws/$ catkin_make

or

~/catkin_ws/$ catkin build

and source your workspace

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 7,548 times

Last updated: Apr 04