Python 2: SyntaxError: Non-ASCII character '\xe2' in file

Dear support community:

I’ve recently (almost) completed the “Command Line Calendar” exercise in Python. When I run the program in the terminal it fails and gives me the following reason:

$ python Calendar.py
File “Calendar.py”, line 1
SyntaxError: Non-ASCII character ‘\xe2’ in file Calendar.py on line 1, but no encoding declared; see PEP 263 – Defining Python Source Code Encodings | peps.python.org for details
$

What does this mean? What should I do to make the program work? I’m in the deep end!

Here’s a link to the exercise: https://www.codecademy.com/courses/learn-python/projects/calendar

Thank you.

Hello,
The error means python has found a character in your code that it doesn’t recognise. A bit of googling suggests it could be a - (possibly arriving via copy/pasting from elsewhere).
Deleting it/them and re-typing should fix it.

Hope that helps

1 Like