How to Run a File in Python – What's the Best Way to Execute a Script? or Struggling with How to Run

18 Replies, 1807 Views

Bro, same. I spent hours figuring out how to run a file in python when I started.

Here’s the cheat code:
1. Open terminal in the folder (or `cd` there).
2. Type `python script.py`. If it fails, try `python3`.
3. If it *still* fails, your Python might not be in PATH. Reinstall it and check that box!

For IDEs, VS Code is king. Install the Python extension, open your file, and click the play button. Done.

Messages In This Thread



Users browsing this thread: 1 Guest(s)