Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics Types and Branching If, Else and Elif

kevin nadjarian
kevin nadjarian
1,498 Points

Python : SyntaxError: invalid syntax

Whatever I do, I receive a Python error:

python hello.py                                                                              

SyntaxError: invalid syntax                                                                      
>>> python hello.py                                                                              
  File "<stdin>", line 1                                                                         
    python hello.py                                                                              
               ^                                                                                 
SyntaxError: invalid syntax

Tried to change the script from the courses or even from external template, always have the same issue

3 Answers

Looks like your problem is that you are trying to run python hello.py from within the Python interpreter, which is why you're seeing that traceback.

Make sure you're out of the interpreter, then run the python hello.py command from bash or command prompt or whatever.

kevin nadjarian
kevin nadjarian
1,498 Points

Yes ... that was it !

Thank you !

I'm getting the same error and I don't understand what to do

Jeffrey Vierra
Jeffrey Vierra
25,404 Points

Hi Mitchel,

I was getting the same error. I found a resolution by upgrading my Python 2.3 to version 3. I'm using a Mac terminal to test out all my Python code. A simple google search "how to upgrade python 2.7 to three" should be a good place to start for you.

Good luck.