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 trialMichael Quiban
2,493 PointsAttempting to run hello.py with python hello.py will return a syntax error. Any way around this?
Hi guys I've pasted the code below:
python hello.py
File "<stdin>", line 1
python hello.py
^
SyntaxError: invalid syntax
I've tried this in an IDE and it displayed no issues.. Any ideas?
4 Answers
Steven Parker
231,268 PointsThat's just the command to start the program running, but the syntax error may be in the file contents. Also, where is it you pasted this? Are you using the workspaces? If so, you can make a "snapshot" and share the link to it here for a complete analysis.
Douglas Jackson
Courses Plus Student 174 PointsI just had the same problem in Workspaces. Turns out I missed the "Ctrl+D" step
Calvin Tiley
7,492 PointsI had the same problem. I just restarted the workspace window and it worked fine. Must just be a bug.
Samet Erpik
1,187 PointsI've reloaded the workspace tab and it worked fine!
Michael Quiban
2,493 PointsMichael Quiban
2,493 Pointshttps://w.trhou.se/9gck5f4ewi
Yeah I know, but the thing is when my file is as simple as (above link) there should be no syntax error. I've even tried removing everything and it still displays invalid syntax when I run an empty file.
Steven Parker
231,268 PointsSteven Parker
231,268 PointsI created a fork (clone) of your workspace and it worked for me:
As you can see, the command causes the Python system to start up, run your program, and then exit when done. But I can re-create the error messages shown above if I enter that command while already running python:
So just remember to only use that command from the command shell, and not from inside an interactive Python session.