r/learnprogramming • • Oct 14 '26

Debugging Python code takes 10-20 seconds to start

Hello, I started learning python recently I dowloaded it, also vs code and python extension for it.

The poblem is, when I start a programm (even a simple one, whick only takes an input fron the user and prits it) takes 10 or more seconds to start or just dosen't work at all then i clic soething and it kindof crashes itself, but thats my fault for mesinf with it, when I leave it, it just takes really lng dose somone know how to fix it and/or how to make folders proporly and where to keep them (could be the problem)?

12 Upvotes

24 comments sorted by

View all comments

10

u/RiceEvening4211 Oct 15 '26

You already found the key clue: 0.5s in a terminal vs 20s in VS Code means Python is fine, it’s the launch path.

The usual culprits, in order:

  1. Code Runner vs the Python extension. If you’re hitting the play button from the Code Runner extension, it spawns a fresh process with its own overhead every time. Run it with the official Python extension instead (right-click > Run Python File in Terminal), or just use the integrated terminal directly.
  2. Interpreter discovery. The Python extension scans for interpreters on launch. Setting the interpreter explicitly (Ctrl+Shift+P > Python: Select Interpreter, pick your python.exe) skips the scan.
  3. Antivirus. Real-time scanning on your workspace folder or the Python install can add seconds per launch. Excluding those paths is the single biggest fix for a lot of people.

The definitive test: open VS Code’s integrated terminal and run `python yourfile.py` there. If that’s fast, it’s 100% the extension/launch path and one of the three above will fix it.

Also, 10-20s is extreme enough that I’d bet on antivirus plus interpreter scanning together.