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 (Retired) Say Hello to Python The Shell

I keep getting error when trying to load python hello.py on console

I keep getting error when trying to load python hello.py on console

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

2 Answers

Hi Joe,

I get that same error when trying to do that within the python shell. To run a python program, we need to be outside the shell.

treehouse:~/workspace$ python hello.py

Hope this helps,

Cheers

thanks bro

O man this thing aint working now... how do i get of the shell

Type exit() from within the shell, to exit it.

Denny Ho
Denny Ho
4,472 Points

Hi Robert, Sorry to sorta hijack this but I was wondering why it is that we can't load a script from within the python shell? So anytime we want to run a python script, we'd have to quit and then do

treehouse:~/workspace$ python script_name.py

every time instead of just typing script_name.py while within the python shell?

got it.. i just understood it. i was confused about why when i type python it took me inside the shell.