Ask Your Question
0

problem in writing a simple service and client(python)

asked 2015-09-17 02:29:49 -0500

ZouQiang gravatar image

updated 2015-09-17 02:33:31 -0500

gvdhoorn gravatar image

When I type

rosrun beginner_tutorials add_two_ints_server.py

it displays

from: can't read /var/mail/beginner_tutorials.srv
/home/exbot/catkin_ws/src/beginner_tutorials/scripts/add_two_ints_server.py: line 4: import: command not found
/home/exbot/catkin_ws/src/beginner_tutorials/scripts/add_two_ints_server.py: line 6: syntax error near unexpected token `('
/home/exbot/catkin_ws/src/beginner_tutorials/scripts/add_two_ints_server.py: line 6: ` def handle_add_two_ints(req):'

how can I solve this question.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2015-09-17 03:15:31 -0500

mgruhler gravatar image

updated 2015-09-17 03:17:42 -0500

It looks like the script is being executed by the shell and not by python. Does your script start with a shebang?

#!/usr/bin/env python

This is required to be recognized as a python node.

Actually, there a quick google turned up mutiple questions about the same thing here on ROS answers http://answers.ros.org/question/16409... http://answers.ros.org/question/14991...

edit flag offensive delete link more

Comments

This is exactly the case. I had this kind of response because I had (accidentally) included a space in front of #!/usr/bin/env python

angelos.p gravatar image angelos.p  ( 2017-03-24 08:35:48 -0500 )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: 2015-09-17 02:29:49 -0500

Seen: 1,587 times

Last updated: Sep 17 '15