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

SyntaxError: invalide syntax | File "<stdin>", line 1

I have created a python-file named "hello_test.py". Can somebody explain (a) what went wrong and (b) how to solve the problem?

print("hello")

treehouse:~/workspace$ python                                       
Python 3.9.0 (default, Oct 30 2021, 01:41:09)                       
[GCC 5.4.0 20160609] on linux                                       
Type "help", "copyright", "credits" or "license" for more informatio
n.                                                                  
>>> python hello_test.py                                            
  File "<stdin>", line 1                                            
    python hello_test.py                                            
           ^                                                        
SyntaxError: invalid syntax

1 Answer

Hi John,

I believe the issue is that you entered the Python REPL, then tried to run your command.

Instead of keying in python at the terminal and then pressing enter, which opens the REPL; try keying in python hello_test.py from the outset.

Thank you Brandon for the answer. Correct solution was to quit/ exit REPL and then keying "python app.py".