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

Console not working???

I keep getting syntax error no matter what line I put into the file. If I run the line in the console its fine but if once I try to run it from the file its syntax error. Ive tried many different lines including putting exactly what he does in the lesson and still syntax error. Any ideas on how I can fix this? https://w.trhou.se/4c4pv16mja

Chris Freeman
Chris Freeman
Treehouse Moderator 68,454 Points

Hi donald, can you share a snapshot of your workspace? There is a camera icon in the upper right of the workspace. Share the link of the snapshot here.

I just added the link. Its a pretty simple string but even that gives syntaxerror

Chris Freeman
Chris Freeman
Treehouse Moderator 68,454 Points

It seems to work for me. Here is my console text:

treehouse:~/workspace$ python hello.py
hello, Donald
treehouse:~/workspace$ 
Chris Freeman
Chris Freeman
Treehouse Moderator 68,454 Points

From the REPL you have already invoked the Python interpreter:

treehouse:~/workspace$ python
Python 3.9.0 (default, Jun 17 2021, 22:35:48)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello, Donald!")
Hello, Donald!
>>> exit()

But from the console command line you have include python before the name of the file as in python hello.py

2 Answers

Yes im doing that exactly. When I run the string in just the console it runs fine, but when I put it in the file like in that link and do python hello.py it says syntax error. I showed it to a friend who knows quite alot about coding exactly what I was doing and he said theres no syntax error and its not on me and that its something wrong with the workspace. Just wondering if anyone knows anyway to reset it for fix this from within the workspace.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,454 Points

Can you copy and paste the contents of the console window with the entire error message?

its working now. I typed in help and then cleared and ran the code again and it started working. Not sure what was wrong.