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

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
221,297 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.