Python Forum

Full Version: Very first Python program generates a syntax error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I typed in my first Python program (Hello World!) EXACTLY as it appeared in print.

#! /usr/bin/python

print "Hello World!"
I used chmod to make it an executable file. When I went to run the file, it generated the following:

  File "./hello.py", line 3
SyntaxError: Non-ASCII character '\xc2' in file ./hello.py on line 3, but no encoding declared

It should have ran just fine. I did notice that on my Pi, when I actually attempt to type in the following characters `~^'" I have to type them in TWICE for them to appear on the screen. And it doesn't matter if I am typing then into IDLE, nano or in the CLI.

Any suggestions?
do od -Ax -tx1 -w32 filename on your script file.
It turns out that the keyboard wasn't mapped quite right in Raspbian Jessie. Once I got that corrected and the program edited, it ran just fine. Thanks for replying Skaperen...