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

Keep having this issue when trying to run a file

I keep getting this same syntax each time I try to call this file.

http://imgur.com/a/9j0wn

I have already read other posts regarding this but haven't found anything beneficial. I have also made sure to check I'm saving the file before trying to run it in the shell.

2 Answers

Steven Parker
Steven Parker
243,658 Points

The file itself is fine.

But when you tried to run it, you were already running Python, so when you typed "python functions.py" you got an error because that is not valid Python code.

You want to use that command at the shell level. So stop Python (type "quit()") to get back to the shell. And then instead of typing just "python", type "python functions.py".

Thank you so much! I was stuck on this just staring at it for awhile trying to figure out.

EDIT:

I didn't refresh the page and see Steve's answer. Please +1 that one, my orig answer below for context :)

orig answer:

Hi there!

Ah okay, what's happening is you're first entering python, then telling python to run python and it's getting confused. Get out of it by typing

quit()

That will return you to the command line prompt, which looks like this:

treehouse:~/workspace$

clear the screen with

treehouse:~/workspace$ clear

then just type

treehouse:~/workspace$ python functions.py