As a very beginner on ROS, I am trying to produce the minimum code for printing "Hello World" on the screen. My Python version: 3.8, operating system: Ubuntu, ROS system: Noetic. This is the simple code I tried:
import rospy
if --name-- == "--main--":
print("hello world")
after entering in the terminal:
runros mypackagename helloWorld.py
error messages come up: import command not found, syntax error unexpected token '"hello world"'
Problem solved! First I had forgotten the header code in the first line, and then I forgot to add the 3 for the correct python version. So, the correct hallo world code is:
#!/usr/bin/python3
if __name__ == '__main__':
print('Hello World!')
Thank you @BTables, for pointing out the syntax error of the double-quotes.