How to Run a Python File
Python is an object oriented, interpreted programming language that is popular with programmers for its modularity, which readily enables code reuse. A Python script file may be run using the Python engine from the Unix/Linux or Windows command prompt. Python script files are simple text files with a file extension of “.py.” Make sure the open source Python engine is installed on the computer and run the Python script file using a command line statement.
Instructions
-
-
1
Open a command prompt on the computer. In Windows, click the Windows “Start” button and then type “cmd” into the Search input box. Press the “Enter” key. The DOS window opens. In Ubuntu, click “Applications” and then click “Accessories.” Click “Terminal” to open the command terminal.
-
2
Type the following statement at the command prompt in both Unix/Linux and Windows. Substitute your file’s name for “filename.”
python filename.py
-
-
3
Press the “Enter” key to run the Python script file.
-
1