anonymous
  • anonymous
Please forgive me if this is too basic...I'm running Python in Linux. It's already installed and I open it through a terminal and not a separate IDLE. I've written my first program, but I don't know how to test it. I don't know how to get Python to look for it in the right place. Does that make sense?
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
s3a
  • s3a
Does cd /the/dir/it/is/in and then python3 filename.py work?
anonymous
  • anonymous
Yeah, as s3a said you can run it with "python filename.py"
s3a
  • s3a
Also, on Debian, I'm pretty sure "python" uses whatever is default but if you use the "python2" or "python3" command, you get to explicitly choose which version you use.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
If I assume you've got a textfile with your python program, you can run it from the python console by calling `execfile( "program.py" )` (or e.g. `execfile( "../test/program.py" )` ). You can also simply call `python program.py` from your terminal. Another way, which is the way I usuallt prefer, is by putting a line in front of your script that tells the terminal how to execute it. You can then simply run your program from the terminal (e.g. ./program.py) if you make it executable. The line will be something like `#!/usr/bin/python` (and it should be the first line in your file). This will also work for perl/ruby/bash scripts.

Looking for something else?

Not the answer you are looking for? Search for more explanations.