How Do I Run a Python File in Ubuntu Terminal?

How Do I Run a Python File in Ubuntu Terminal?
Contents

How do I run a .PY file in Terminal?

To run Python scripts with the python command, you need to open a command-line and type in the word python , or python3 if you have both versions, followed by the path to your script, just like this: $ python3 hello.py Hello World!

How do I run a python3 file in Ubuntu?

Option 1: Call the interpreter

  1. For Python 2: python .py.
  2. For Python 3: python3 .py.
Elena Rostova
Author

Elena Rostova

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.