Visual Studio Code Python Timeout waiting for debugger connection

42,976

Solution 1

Open the launch.json file and add the following configuration:

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

When you specify none internalConsole for the console, it will run the debugger in the debugger console instead of running in the internal or external terminal.

Solution 2

I had the same issue, so I added the following line to the settings.json file:

{
    // to fix 'Timeout waiting for debugger connections'
    "python.terminal.activateEnvironment": false
}

Solution 3

I had this same problem today. I think it might be a connection problem when the debugger tries to connect to an integrated PowerShell terminal inside Visual Studio. If I change to using an external terminal to run the program then it works okay, and the debugger connects to the external terminal and I can debug perfectly fine. This is my entry for the external terminal launch in launch.json

{
    "name": "Python: Terminal (external)",
    "type": "python",
    "request": "launch",
    "program": "${file}",
    "console": "externalTerminal"
},

Solution 4

I had the same issue. fixed by use "integratedTerminal".
ps.my system win7

{
            "name": "Debug",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/main.Py",
            "console": "integratedTerminal"
}

Solution 5

Change your integrated terminal shell to cmd.exe. This will allow the default launch.json to debug with the Current File (Integrated Terminal) option.

This change has fixed other bugs in my Visual Studio Code + Python integration, such as the double call to Run Python File in Terminal that was frequently required. It was a nice suggestion coming from an internal dialog in version 1.28.2.

Share:
42,976
bearcat
Author by

bearcat

Updated on February 07, 2022

Comments

  • bearcat
    bearcat over 2 years

    I'm running the visual studio code tutorial with Python and am unable to connect to the debugger. Google / SO are coming up empty when I search. Usually I use Anaconda with Jupyter, so I'm connecting Visual Studio Code to the python in my activated 3.6 virtual environment. I tried pip installing ptvsd in my virtual environment, but that did not make a difference in what I am seeing.

    I would welcome any suggestions. Screenshots included below. launch.json in the bottom screenshot

    enter image description here enter image description here