0

I know how to run a python script from the python idle but I can't figure out how to run it from the terminal.

I thought that it might work by using "run test.py"

print("Hello World")
print("This is a test")
print(1+1)
0

2 Answers 2

0

To run a python script, you just have to write python YOUR FILE HERE.py But before doing this, remember to set the location of command prompt to the location of your file using the command cd YOUR FILE ADDRESS

Sign up to request clarification or add additional context in comments.

4 Comments

You can run a file in any directory; the current working directory is just a convenience which removes the requirement to write out the path. See also What exactly is current working directory?
Separately, file names with spaces in them need to be quoted or otherwise disambiguated. What exactly works depends on your platform. For Windows, probably use double quotes.
python may or may not work. On Windows, probably try py instead. On some Linux platforms, you want python3. But again, all of this and more is thoroughly explained in existing duplicates; please don't post new answers to simple questions when a duplicate probably contains more details and nuance than you are able or willing to put in a new answer.
Ok I am new to the platform, will try to improve this next time. Thank you for your help!
0

you can call the Python program from the Command Prompt and tell it which file to execute. From the Command Prompt, simply type:

python test.py

For more information visit this link:

Here

Comments