Python Forum
Very first Python program generates a syntax error
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Very first Python program generates a syntax error
#1
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?
Reply
#2
do od -Ax -tx1 -w32 filename on your script file.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#3
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...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Syntax error for "root = Tk()" dlwaddel 15 1,008 Jan-29-2024, 12:07 AM
Last Post: dlwaddel
Photo SYNTAX ERROR Yannko 3 333 Jan-19-2024, 01:20 PM
Last Post: rob101
  Syntax error while executing the Python code in Linux DivAsh 8 1,451 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Code is returning the incorrect values. syntax error 007sonic 6 1,135 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  unittest generates multiple files for each of my test case, how do I change to 1 file zsousa 0 918 Feb-15-2023, 05:34 PM
Last Post: zsousa
  syntax error question - string mgallotti 5 1,250 Feb-03-2023, 05:10 PM
Last Post: mgallotti
  Syntax error? I don't see it KenHorse 4 1,194 Jan-15-2023, 07:49 PM
Last Post: Gribouillis
  Syntax error tibbj001 2 847 Dec-05-2022, 06:38 PM
Last Post: deanhystad
  Python-for-Android:p4a: syntax error in main.py while compiling apk jttolleson 2 1,777 Sep-17-2022, 04:09 AM
Last Post: jttolleson
  Mysql Syntax error in pymysql ilknurg 4 2,288 May-18-2022, 06:50 AM
Last Post: ibreeden

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020