Skip to content

Instantly share code, notes, and snippets.

@minorua
Last active September 27, 2024 11:51
Show Gist options
  • Save minorua/b31793cff6e453c121adc0c78bae7f39 to your computer and use it in GitHub Desktop.
Save minorua/b31793cff6e453c121adc0c78bae7f39 to your computer and use it in GitHub Desktop.
Debugging a QGIS plugin with VS Code

QGIS

  1. ScriptRunnerでdebugpy_OSGeo4W.pyを実行。

VS Code

  1. 次で.vscode/launch.jsonを作成。remoteRootを${workspaceFolder}に変更。

Menu / Run / Add Configuration…

  • Python Debugger
  • Debug Configuration: Remote Attach
  • Enter the host name: localhost
  • Enter the port number: 5678
  1. デバッグ開始。

Menu / Run / Start Debugging

import debugpy
debugpy.configure(python="C:/OSGeo4W/bin/python3.exe") # https://github.com/microsoft/debugpy/issues/262
port = 5678
debugpy.listen(port)
{
// 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 Debugger: Remote Attach",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment