This document provides help with simple running - especially if you have never run a program before.
On Windows, running python is quite simple, just make sure you have installed Python:
- Visit python.org
- Download the latest version of python for Windows
- Open the download box (likely in the lower left corner of your screen) and run the installer
- IMPORTANT: when prompted to add Python to PATH, make sure to check the box, otherwise you won't be able to run python easily
- Open a command prompt (cmd) - the easiest way is to press the windows key on your keyboard (between left ALT and CTRL) and type "cmd"
- Go to the directory of the python file you want to run - if you open File Explorer there is a path to each file, which you can type in manually or copy. It should look something like:
C:\Users\<username>\Desktop\Code\
, in cmd, type:cd
, followed by the path. - Run
python filename.py
- After pressing
ENTER
, you should see the result of your code.
On Linux, python3 should be preinstalled. There are two ways to run a python file:
To run a file in the current directory, ensure the first line of the file has the location of the executable you want to use, for example:
#!/bin/python3
Then, you can run your python file as:
./filename.py
For this to work, the first line doesn't have to be anything specific, but the run command is slightly longer:
python3 filename.py