Ask Your Question
0

ImportError: No module named waypoint_listener.srv

asked 2016-03-28 16:45:10 -0600

torugobeck gravatar image

I'm trying to create a service, but i can't use it in python(didn't tested in C++).

I have the following CMakeList file

cmake_minimum_required(VERSION 2.8.3)
project(waypoint_listener)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  rospy
  geometry_msgs
  message_generation
)


## Generate services in the 'srv' folder
 add_service_files(
   FILES
   WaypointServer.srv
#   Service1.srv
#   Service2.srv

 )


## Generate added messages and services with any dependencies listed here
 generate_messages(
   DEPENDENCIES
   geometry_msgs
 )


catkin_package(
 INCLUDE_DIRS
 CATKIN_DEPENDS message_runtime rospy geometry_msgs


)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
  ${catkin_INCLUDE_DIRS}
)

in python file i imported the srv file, this way

from waypoint_listener.srv import *

but i'm getting the following error

Traceback (most recent call last):
  File "/home/vitor/catkin_ws/src/viz/waypoint_listener/scripts/waypoints_server.py", line 5, in <module>
    from waypoint_listener.srv import *
ImportError: No module named srv
edit retag flag offensive close merge delete

Comments

Did you solve the problem?

Ugnius Malukas gravatar imageUgnius Malukas ( 2018-07-31 02:36:27 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-03-28 19:59:39 -0600

I don't have much experience with python, I do most of my work in C++ but did you execute catkin_make in your work space? You probably need to run it to auto-generate your service's python modules.

Hope this helps

edit flag offensive delete link more

Comments

I already executed catkin_make, and tried to delete de build and devel folders, and run again, in order to get a 'clean build', actually the PyCharm IDE shows me the module, but even after adding "devel/setup.bash" to the bash terminal, can't run the code

torugobeck gravatar imagetorugobeck ( 2016-03-28 22:03:47 -0600 )edit

You need to run source devel/setup.bash, not devel/setup.bash. You might also need to start PyCharm from the terminal where you sourced the workspace (but that would depend on how it interacts/treats the PYTHONPATH).

gvdhoorn gravatar imagegvdhoorn ( 2016-03-29 05:28:29 -0600 )edit

sorry for the misunderstood, but I runned souce devel/setup.bash, and have it in .bashrc, and after catkin_make I update my terminal, opening a new one, or running source devel/setup.bash . In order to use PyCharm I followed this tutorial http://wiki.ros.org/IDEs#PyCharm_.28c...

torugobeck gravatar imagetorugobeck ( 2016-03-29 06:41:55 -0600 )edit

when i run the code from pycharm, there is no error.

torugobeck gravatar imagetorugobeck ( 2016-03-29 06:46:06 -0600 )edit

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2016-03-28 16:45:10 -0600

Seen: 686 times

Last updated: Mar 28 '16