Skip to content

VSCode does not execute Python files after clean Windows reinstall (process hangs and exits silently) #25711

Closed

Description

@Julian7668

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.107.1 (Stable)
  • OS Version: Windows 10 (fresh install)

Steps to Reproduce:

  1. Perform a clean Windows reinstall.
  2. Install Python from python.org (not from Microsoft Store).
  3. Verify that Python works correctly from CMD (python, pip, running scripts).
  4. Install Visual Studio Code (stable) and open it.
  5. Manually select the Python interpreter located at:
    C:\Users\...\AppData\Local\Programs\Python\Python312\python.exe
  6. Create a simple test.py file (e.g. print("test")).
  7. Run the file using the Run button or by pressing F5.

Observed Result:

  • VS Code stays in a “running” state with no output.
  • No error is shown in the terminal.
  • When closing the run tab, an error briefly flashes and disappears.
  • The Python script does not execute.

Expected Result:

  • The Python file should execute normally, the same way it does when run from CMD or from the VS Code integrated terminal using python test.py.

Additional Notes:

  • The issue occurs even with all extensions disabled.
  • Running python test.py from the VS Code integrated terminal works correctly.
  • Before the Windows reinstall, the same setup worked correctly on this machine.

Activity

  1. eleanorjboyd commented on Jan 5, 2026

    @eleanorjboyd
    Member

    How do you do: "Manually select the Python interpreter located at: C:\Users...\AppData\Local\Programs\Python\Python312\python.exe"

  2. eleanorjboyd commented on Jan 5, 2026

    @eleanorjboyd
    Member

    additionally if you could check your logs for the python extension and include those that would be great!

  3. jmpcm commented on Jan 6, 2026

    @jmpcm

    I'm having the same problem, but in Linux. I don't see any information in the logs window.

    Not sure how this is related, but setting "python.useEnvironmentsExtension" : true solved the issue. See issue #25694.

  4. Julian7668 commented on Jan 6, 2026

    @Julian7668
    Author
    Image

    I previously selected the second option, where I chose the location of python.exe on my computer, and now I have the third option, which is what I meant by “Manually select the Python interpreter located at: C:\Users...\AppData\Local\Programs\Python\Python312\python.exe.” I disabled all extensions and enabled only the Python one, but it keeps loading indefinitely, as shown in the following image.

    Image
  5. eleanorjboyd commented on Jan 7, 2026

    @eleanorjboyd
    Member

    Could you please run the Python Environment Tool and share the output? Here’s how:

    1. Open VS Code
    2. Press Ctrl/Cmd+Shift+P
    3. Run: Python: Run Python Environment Tool (PET) in Terminal...
    4. When prompted, choose “Search all”
    5. Wait until it finishes and a terminal called “Python Environment Tool” appears at the bottom
    6. Copy everything printed there and paste it here (or attach it as a text file)

    This will show us which environments VS Code detected and how they were resolved and this might show us why they aren't finishing in the UI here

  6. Julian7668 commented on Jan 7, 2026

    @Julian7668
    Author

    I got to step 3 and was given these two options:
    Image

    Once I hit the first one, it sent me to the console, and this is what I saw on the console: """
    PS F:\Proyectos\Roblox> & c:\Users\julia.vscode\extensions\ms-python.vscode-python-envs-1.15.13521015-win32-x64\python-env-tools\bin\pet.exe find --verbose
    PS F:\Proyectos\Roblox>
    """, it seems that nothing is running.

    I clicked on the second one and it asked me to give it the path to python.exe on my computer. Once I gave it the path, the console displayed: """
    PS F:\Proyectos\Roblox> & c:\Users\julia.vscode\extensions\ms-python.vscode-python-envs-1.15.13521015-win32-x64\python-env-tools\bin\pet.exe resolve C:\Users\julia\AppData\Local\Python\pythoncore-3.14-64\python.exe
    PS F:\Proyectos\Roblox>
    """.

    I went to the exit and these are the exits I see:

    Python
    Image
    """
    2026-01-07 11:09:34.463 [info] El experimento "pythonSurveyNotification" está activo
    2026-01-07 11:09:34.561 [info] Native locator: Refresh started
    2026-01-07 11:09:34.612 [info] > pyenv which python
    2026-01-07 11:09:34.612 [info] cwd: .
    """

    Python Debugger
    Image

    Python Environments
    """
    2026-01-07 11:09:34.464 [info]
    === Python Envs Configuration Levels ===
    2026-01-07 11:09:34.464 [info] {
    "section": "Python Envs Configuration Levels",
    "defaultEnvManager": {
    "workspaceFolderValue": "undefined",
    "workspaceValue": "undefined",
    "globalValue": "undefined",
    "defaultValue": "ms-python.python:venv"
    },
    "defaultPackageManager": {
    "workspaceFolderValue": "undefined",
    "workspaceValue": "undefined",
    "globalValue": "undefined",
    "defaultValue": "ms-python.python:pip"
    }
    }
    2026-01-07 11:09:34.464 [info] [pet] Starting Python Locator c:\Users\julia.vscode\extensions\ms-python.vscode-python-envs-1.15.13521015-win32-x64\python-env-tools\bin\pet.exe server
    2026-01-07 11:09:34.583 [info] getAllExtraSearchPaths completed. Total unique search directories: 0 Paths: []
    2026-01-07 11:09:34.585 [info] [pet] configure: Sending configuration update: {"workspaceDirectories":["f:\Proyectos\Roblox"],"environmentDirectories":[],"poetryExecutable":"poetry","cacheDirectory":"c:\Users\julia\AppData\Roaming\Code\User\globalStorage\ms-python.vscode-python-envs\pythonLocator"}
    2026-01-07 11:10:36.581 [info] Running PET find command: c:\Users\julia.vscode\extensions\ms-python.vscode-python-envs-1.15.13521015-win32-x64\python-env-tools\bin\pet.exe find --verbose
    2026-01-07 11:17:15.108 [info] Running PET find command: c:\Users\julia.vscode\extensions\ms-python.vscode-python-envs-1.15.13521015-win32-x64\python-env-tools\bin\pet.exe find --verbose
    2026-01-07 11:20:42.259 [info] Running PET resolve command: c:\Users\julia.vscode\extensions\ms-python.vscode-python-envs-1.15.13521015-win32-x64\python-env-tools\bin\pet.exe resolve "C:\Users\julia\AppData\Local\Python\pythoncore-3.14-64\python.exe"
    """

  7. eleanorjboyd commented on Jan 8, 2026

    @eleanorjboyd
    Member

    you should be able to run c:\Users\julia.vscode\extensions\ms-python.vscode-python-envs-1.15.13521015-win32-x64\python-env-tools\bin\pet.exe find --verbose from your terminal for the same results. If you could try that and get the logs that would be great- sorry!

  8. Julian7668 commented on Jan 8, 2026

    @Julian7668
    Author

    I ran the Python Environment Tool (pet.exe) directly from my system terminal, outside of VS Code, using the exact path you provided.

    I verified that:

    • The extension ms-python.vscode-python-envs-1.15.13521015-win32-x64 exists.
    • python-env-tools/bin/pet.exe exists and is executable.

    When running the following command from PowerShell:

    & "C:\Users\julia\.vscode\extensions\ms-python.vscode-python-envs-1.15.13521015-win32-x64\python-env-tools\bin\pet.exe" find --verbose
    

    the process exits immediately with no output at all (no stdout, no stderr, no logs), even with --verbose.

    This matches the behavior seen when running PET from VS Code:

    • pet.exe find --verbose is invoked (confirmed in the Python Environments logs),
    • but it never produces output or completes environment resolution.

    This also explains why:

    • Python scripts hang when run via VS Code (Run / F5),
    • no errors are shown,
    • but running python test.py directly from the integrated terminal works correctly.

    Since pet.exe shows the same silent behavior when executed independently of VS Code, this seems to indicate an issue with PET itself (or its interaction with the system after a clean Windows install), rather than a VS Code UI or configuration problem.

    Please let me know if you’d like me to collect additional diagnostics or try a specific PET build or flag.

  9. eleanorjboyd commented on Jan 9, 2026

    @eleanorjboyd
    Member
  10. DonJayamanne commented on Jan 13, 2026

    @DonJayamanne

    & "C:\Users\julia.vscode\extensions\ms-python.vscode-python-envs-1.15.13521015-win32-x64\python-env-tools\bin\pet.exe" find --verbose

    Can you try running this in command prompt.
    Its also possible you have some anti virus software or the like that might be blocking this executable.

  11. Julian7668 commented on Jan 15, 2026

    @Julian7668
    Author

    Root cause identified and resolved.

    After the clean Windows reinstall, the Microsoft Visual C++ Redistributable (VC++ 14.x / 2015–2022, x64) was not installed on the system. As a result, pet.exe failed to start due to a missing VCRUNTIME140.dll.

    Because pet.exe could not launch, it exited immediately and silently (no stdout/stderr). This caused:

    • Python execution via VS Code (Run / F5) to hang indefinitely
    • No visible errors in VS Code
    • Normal execution when running python script.py directly from the terminal (since PET is not involved)

    Once the Visual C++ Redistributable 2015–2022 (x64) was installed and the system rebooted:

    • pet.exe find --verbose runs correctly
    • Python execution via VS Code works as expected again

    This appears to be a dependency assumption issue after a clean Windows install, where the required VC++ runtime is not present by default.

    Thank you all for your help. Without your assistance, I would not have been able to fix the bug that was preventing me from working comfortably. I hope this also helps in future cases!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

triage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions