Search code examples
pythonvisual-studio-code

vscode spends long time beginning to run the python file


Recently I updated my Visual Studio Code to version 1.94 (September 2024). By then, It took a long time to run my code when I pressed the "Run Python File" button. This problem applies to every Python file I try to execute (no matter how long the file is or where the file is in). The time that the terminal is opened and the execution time itself is the same as before, but it takes a few seconds until the one-line command (path of python intepreter) "(path of python file)" appears after the terminal window appears.

To make the file start at a normal time in VSCode, I tried these things: changing the file's directory, rebooting VSCode and my laptop, using PowerShell instead of cmd, etc. But none of these worked to fix my problem. Also, this problem did not occur when I used different editors (such as IDLE).

Here are the versions and specifications of my software: 10.0.22631.4169 (Windows), 3.12.6 (Python), 1.94 (VSCode). Also, here are the extensions I use with VSCode: Black Formatter, indent-rainbow, Material Icon theme, Pylance, Python, Python Debugger. Additionally, I use cmd as the default terminal (not PowerShell).


Solution

  • the problem is in the version of the extension,

    the new extension is really slow,

    so the solution is to delete the extension then restart VS-code,

    after that open it and search about python and click on the gear:

    first image

    then after that install this version:

    2024.14.0

    second image

    then restart you VS-code and try