Error: No module named basics.srv

asked 2016-07-20 22:27:12 -0600

yunxiao gravatar image

I have checked several solutions, but they can not solve my problem. The CMakeList.txt: ............................

find_package(catkin REQUIRED COMPONENTS
        roscpp
        rospy
        std_msgs
        message_generation          #   Add message_generation  here,   after   the other   packages

)

add_service_files(
FILES
WordCount.srv

)

catkin_package(
CATKIN_DEPENDS message_runtime

)

add_message_files(
FILES
Complex.msg

)

generate_messages(
DEPENDENCIES
std_msgs

)

rosbuild_init()
rosbuild_genmsg()
rosbuild_gensrv()

The package.xml:

 `<build_depend>rospy</build_depend>`
 <run_depend>rospy</run_depend>
<build_depend>message_generation</build_depend>
<build_depend>message_generation</build_depend>
<run_depend>message_runtime</run_depend>
<depend package="rospy" />
 <depend package="actionlib_msgs" />

I use the rossrv list, I can see basics/WordCount. The following are the python code:

#!/usr/bin/env python

import rospy

from basics.srv import WordCount,WordCountResponse


def count_words(request):
return WordCountResponse(len(request.words.split()))
rospy.init_node('service_server')

service = rospy.Service('word_count', WordCount, count_words)

rospy.spin()

So what should be possible reason for that?

edit retag flag offensive close merge delete