Rosrun move_bb8_pkg move_bb8_square.py takes too long?

Hello guys,

I’m taking Linux for robotics course right now and I’m on exercise 3.1.

My question is why rosrun move_bb8_pkg move_bb8_square.py execution takes forever to run. Eventually when I use ctrl + c to close the execution. I get this error!

^Cfrom: can’t read /var/mail/geometry_msgs.msg
^C^C/home/user/catkin_ws/src/linux_course_files/move_bb8_pkg/my_scripts/move_bb8_square.py: line 6: syntax error near unexpected token (' /home/user/catkin_ws/src/linux_course_files/move_bb8_pkg/my_scripts/move_bb8_square.py: line 6: class MoveBB8():’

I don’t know what to do?

Hi @leonar29 ,

this happens because your python script is being interpreted as a bash script.

To solve the problem you just have to add the following code to the first line of your script:

#! /usr/bin/env python

This way, when the script is executed, python will be used to run your script instead of bash.

Cheers.

1 Like

Thank you so much! it worked!

1 Like

Hello all, I am totally new to Linux and ROS. I am practicing on these tutorials. I got similar error but not exactly same. Actually, it gives this when I try to implement the “rosrun” command >>
user:~/catkin_ws/src/linux_course_files/move_bb8_pkg/my_scripts
$ rosrun move_bb8_pkg move_bb8_square.py
import: unable to grab mouse ': Resource temporarily unavailable @ error/xwindow.c/XSelectWindow/9204. from: can't read /var/mail/geometry_msgs.msg import: unable to grab mouse ‘: Resource temporarily unavailable @ error/xwindow.c/XSelectWindow/9204.
import: unable to grab mouse ': Resource temporarily unavailable @ error/xwindow.c/XSelectWindow/9204. /home/user/catkin_ws/src/linux_course_files/move_bb8_pkg/my_scripts/move_bb8_square.py: line 8: syntax error near unexpected token (’
/home/user/catkin_ws/src/linux_course_files/move_bb8_pkg/my_scripts/move_bb8_square.py: line 8: `class MoveBB8():’

What should I do to rectify it?

Hi @arjun2312,

if your script does not have that line:

#! /usr/bin/env python

then you have to add it to the first line of your script.

All python scripts executed with rosrun needs that code in the first tline.

1 Like