Time out waiting for launcher to connect in VS code
Asked Answered
F

4

8

I did python debugging in VS code. The following is the launch.json file:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "stopOnEntry": false,
            "python": "${command:python.interpreterPath}",
            "program": "${file}",
            "cwd": "${workspaceFolder}",
            "env": {},
            "envFile": "${workspaceFolder}/.env",
            "debugOptions":[
                "RedirectOutput"
            ],
            "console": "integratedTerminal"
        }
    ]
}

The following is settings.json file:

{
    "python.pythonPath": "c:\\Users\\susan\\Documents\\PythonScripts\\venv\\Scripts\\python.exe",
    // to fix 'Timeout waiting for debugger connections'
    "python.terminal.activateEnvironment" : false
}

When I debug the python script in VS code, I got Time out waiting for launcher to connect and cannot debug the python script.

May I know how can I solve this issue?

Freestone answered 19/4, 2022 at 5:24 Comment(0)
X
10

Its very simple. Open the launch.json file and add the following into it:

{
  "name": "Python: Debug Console",
  "type": "python",
  "request": "launch",
  "program": "${file}",
  "console": "internalConsole"
}

Then save and exit it. Whatever you do, DO NOT clear the text already in there or else it may make it worser

Xylina answered 19/4, 2022 at 5:33 Comment(6)
Thank you @Xylina after modifying the launch.json file, I don't get the timeout issue.Freestone
Welcome @Susan.Xylina
I can debug only first time with no timeout issue after modifying the launch.json file. After writing a few codes and try to debug again, I got the same time out issue.Freestone
My issue got resolved by using the line "name": "Python: Debug Console",Cryptogenic
This works. Thanks. can you explain a bit why switching to internalConsole solves it ?Timothee
Thank you so much. I spent hours fighting this, god bless you.Frantic
C
5

If for whatever reason "internalConsole" isn't a good solution:

in your shell script:

  export PROCESS_SPAWN_TIMEOUT=30

or just hack the code directly (will be reverted if you update the extension):

.vscode-server/extensions/ms-python.python-2022.18.2/pythonFiles/lib/python/debugpy/adapter/launchers.py[161]:

change:

timeout=(None if sudo else common.PROCESS_SPAWN_TIMEOUT)

to:

timeout=30,
Crispi answered 23/11, 2022 at 4:44 Comment(1)
This works for my case where integrated terminal takes longer than usual to start. I have to increase timeout to 60.Bullace
A
0

Check your firewall settings

Could be the case that the connection on localhost to the python debugger is blocked by your firewall!

Arredondo answered 19/12, 2023 at 8:4 Comment(0)
V
0

I had the same problem in Windows. After changing "console": from "internalTerminal" to "internalConsole" I realized I was missing and double backslash \\ in one of the args. The error message was misleading.

Vinson answered 20/5 at 20:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.