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

Borislav Yordanov
Borislav Yordanov
4,800 Points

Can't run script in the shell

I am trying to run a script in the shell. Here is what I'm trying to do. treehouse:~/workspace$ python
Python 3.5.0 (default, Apr 5 2016, 17:53:30)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.

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

2 Answers

Steven Parker
Steven Parker
230,274 Points

If you type "python" by itself as a shell command, you start python running in the interactive mode. You can't give shell commands inside python.

You can tell you're inside python because the prompt changes to ">>>".

If you want to enter another shell command you must first exit python. Type: quit(). Then, when you see the shell prompt (treehouse:~/workspace$), you can enter a new shell command.