Ask Your Question
0

python syntax error for rosrun .py script

asked 2017-12-30 10:07:11 -0600

KevinH gravatar image

updated 2017-12-30 11:54:18 -0600

gvdhoorn gravatar image

Hello I'm a noob at python, I downloaded this github package (turtlesim_hunter) Then when I rosrun I get a syntax error:

knives@knives:~/catkin_ws/src/turtlesim_hunter/src/turtlesim_hunt/Scripts$ rosrun turtlesim_hunt hunt.py
  File "/home/knives/catkin_ws/src/turtlesim_hunter/src/turtlesim_hunt/Scripts/hunt.py", line 151
    print "Found #" + str(huntedTurtles) + " after " + str(finalTime) + " Current Avg: " + str(totalHuntTime / huntedTurtles)
                  ^
SyntaxError: invalid syntax

The issue is at line 151 in the hunt.py script:

https://github.com/tiedyedguy/turtles...

print "Found #" + str(huntedTurtles) + " after " + str(finalTime) + " Current Avg: " + str(totalHuntTime / huntedTurtles)

I don't know whats wrong and I can't google myself to a specific answer, is the issue that this was written with python 3 and I only have python 2.7 installed? I highly doubt this guy has an error in his code since it's working for him:

https://www.youtube.com/watch?v=LywSO...

edit retag flag offensive close merge delete

Comments

1

Try commenting out that line (put a # in front of it), and if you want to see what it was printing gradually restore it - just print the huntedTurtles bit and put the hash after but before the plus sign with the rest of it, then move the hash to the right so more and more of the line will print

lucasw gravatar imagelucasw ( 2018-01-02 12:20:32 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-01-03 11:44:00 -0600

Try enclosing your print parameters in brackets, this fixed the problem for me:

print ("Found #" + str(huntedTurtles) + " after " + str(finalTime) + " Current Avg: " + str(totalHuntTime / huntedTurtles))

Hope this helps.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-12-30 10:07:11 -0600

Seen: 338 times

Last updated: Jan 03 '18