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?
Issue Type: Bug
Behaviour
Hi, I use the VS Code as my daily IDE. Usually my project is on a remote centos server, and it’s a web project in a docker container. And I develop the project in a remote mode by extension «Remote — SSH» extension, and debug by «Docker» extension (version: v1.22.1) and «Python» extension (version: v2022.10.0).
Recently I found that I’m not able to debug my project as VS Code told my «Timed out waiting for launcher to connect», like the image below:
but when I just switch to VS Code(v1.64.2)(python extension version is v2022.4.0), this error disappears and I’m able to debug, so I guess there should be a bug or a settings about the connect time.
After testing, I found that when the VS Code version is v1.69.1, but the python extension version is v2022.4.0, I’m able to debug, but when the python version is v2022.4.1, this error will alert and I can’t debug
Expected vs. Actual
Expected
Able to debug the project
Actual
Timed out waiting for launcher to connect
Steps to reproduce:
It’s hard to prepare such a project for you to reproduce it, is there any other things I can do to provide you?
this is my launch.json and tasks.json settings:
launch.json
{
"configurations": [
{
"name": "Docker: Python - General",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"python": {
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/app"
}
],
"projectType": "flask",
"justMyCode": true
},
}
]
}
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "docker-run",
"label": "docker-run: debug",
"dependsOn": ["docker-build"],
"dockerRun": {
"containerName": "my_name",
"image": "my_name:my_tag",
"env": {
"FLASK_APP": "/app/web_app/run.py",
"FLASK_ENV": "development"
},
"volumes": [
{
"containerPath": "/app",
"localPath": "${workspaceFolder}"
}
],
"ports": [{
"containerPort": 5000,
"hostPort": 5000
}],
"remove": true
},
"python": {
"args": ["run", "--host", "0.0.0.0", "--port", "5000"],
"module": "flask"
}
},
{
"label": "docker-build",
"type": "docker-build",
"dockerBuild": {
"context": "${workspaceFolder}",
"dockerfile": "${workspaceFolder}/Dockerfile",
"tag": "my_name:my_tag"
}
}
]
}
Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.7.8
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
- Value of the
python.languageServer
setting: Pylance
Please be aware that in my project in docker, the Diagnostic data is:
- Python version (& distribution if applicable, e.g. Anaconda): 3.6.6
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
> conda info --json
DAP Server launched with command: /path/.conda/envs/env/bin/python /path/.vscode-server/extensions/ms-python.python-2022.10.0/pythonFiles/lib/python/debugpy/adapter
User Settings
languageServer: "Pylance"
formatting
• provider: "black"
• blackArgs: "<placeholder>"
tensorBoard
• logDirectory: "<placeholder>"
Extension version: 2022.10.1
VS Code version: Code 1.69.1 (Universal) (b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a, 2022-07-12T08:21:51.333Z)
OS version: Darwin x64 21.3.0
Restricted Mode: No
Remote OS version: Linux x64 3.10.0-1160.el7.x86_64
System Info
Item | Value |
---|---|
CPUs | Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (12 x 2600) |
GPU Status | 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled metal: disabled_off multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_renderer: enabled_on video_decode: enabled video_encode: enabled webgl: enabled webgl2: enabled |
Load (avg) | 3, 3, 3 |
Memory (System) | 16.00GB (2.26GB free) |
Process Argv | —crash-reporter-id cb146214-9dd0-46e1-af43-c01b6d14e1c6 |
Screen Reader | no |
VM | 0% |
Item | Value |
---|---|
Remote | SSH: 5 |
OS | Linux x64 3.10.0-1160.el7.x86_64 |
CPUs | Intel(R) Xeon(R) Silver 4110 CPU @ 2.10GHz (32 x 2399) |
Memory (System) | 502.67GB (309.02GB free) |
VM | 0% |
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vscscmwlcmt:30465135
cppdebug:30492333
pylanb8912:30520716
vsclangdf:30486550
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?
>Solution :
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
The below is my 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",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
Could someone please help with this?
Not sure why i am getting this error.
I ran the code in an online python compiler where it worked fine.
So i can say that there is no error in the code.
Still not sure why the pop up is showing up suddenly.
All help are greatly appreciated!!
Я выполнял отладку Python в коде VS. Ниже приведен файл launch.json:
{
// 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"
}
]
}
Ниже приведен файл settings.json:
{
"python.pythonPath": "c:\Users\susan\Documents\PythonScripts\venv\Scripts\python.exe",
// to fix 'Timeout waiting for debugger connections'
"python.terminal.activateEnvironment" : false
}
Когда я отлаживаю скрипт Python в коде VS, я получаю Time out waiting for launcher to connect
и не могу отлаживать скрипт Python.
Могу ли я узнать, как я могу решить эту проблему?
1 ответ
Это очень просто. Откройте файл launch.json
и добавьте в него следующее:
{
"name": "Python: Debug Console",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "internalConsole"
}
Затем сохраните и выйдите из него. Что бы вы ни делали, НЕ очищайте текст, который уже есть, иначе это может сделать его хуже.
2
Soundwave
19 Апр 2022 в 08:33