Ask Your Question
0

importerror:no module named basic.msg

asked 2017-01-20 00:31:38 -0500

hywel1994 gravatar image

updated 2017-01-20 00:38:12 -0500

Hi, I have a problem on creating msg and writing publisher(python). when I creating msg and 'catkin_make', there is no error. But when I try to run the python node (rosrun baisc message_publisher.py), I got a error:

Traceback (most recent call last):
  File "/home/hywel/catkin_ws/src/basic/scripts/message_publisher2.py", line 4, in <module>
    from basic.msg import Complex2
ImportError: No module named basic.msg

the basic tree:

basic/
├── CMakeLists.txt
├── msg
│   └── Complex2.msg
├── package.xml
├── scripts
│   ├── message_publisher2.py
│   └── message_subcriber2.py
└── src

my CMakelists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(basic)
find_package(catkin REQUIRED COMPONENTS
  rospy
  std_msgs
  message_generation
)
## Generate messages in the 'msg' folder
add_message_files(
  FILES
  Complex2.msg
#   Message1.msg
#   Message2.msg
)
## Generate added messages and services with any dependencies listed here
generate_messages(
  DEPENDENCIES
  std_msgs
)
catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES basic
#  CATKIN_DEPENDS rospy std_msgs

 CATKIN_DEPENDS message_runtime
       #  DEPENDS system_lib
 )

 # include_directories(include)
 include_directories(
     ${catkin_INCLUDE_DIRS}
 )

my package.xml:

<?xml version="1.0"?>
<package>
  <name>basic</name>
  <version>0.0.0</version>
  <description>The basic package</description>
  <maintainer email="hywel@todo.todo">hywel</maintainer>
  <license>TODO</license>
  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>message_gengeration</build_depend>
  <run_depend>message_runtime</run_depend>
  <run_depend>rospy</run_depend>
  <run_depend>std_msgs</run_depend>

  <export>
  </export>
</package>

Thanks!

hywel

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2017-01-20 00:52:54 -0500

hywel1994 gravatar image

updated 2017-01-20 06:05:55 -0500

gvdhoorn gravatar image

Hahaha. I find the answer #q246689.

I didn't do soure ...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-01-20 00:31:38 -0500

Seen: 622 times

Last updated: Jan 20 '17