Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

importerror:no module named basic.msg

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

importerror:no module named basic.msg

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! Thanks!

hywel