Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 67,464 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 67,464 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 67,464 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 67,464 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.