How to Run a Python Script in Terminal?

Open Terminal

Navigate to the script folder with `cd /path/to/folder`

Run the script with `python script.py`

If needed, use `python3 script.py`

If the script needs arguments, use `python script.py arg1 arg2`

If using a virtual environment, activate it first

If the file is not in the current folder, provide the full path with `python /full/path/script.py`

Suggested for You

Trending Today