-
Open QGIS.
-
Click on "Plugins"->"Manage and install plugins"
-
Search for debugvs. Click on "Install Plugin"
-
If you are on Windows, then fix %appdata%\QGIS\QGIS3\profiles\default\python\plugins\debug_vs_init_.py file
try: import debugpy self.debugpy = debugpy self.debugpy.configure(python = 'python3') # New line except: pass
-
Install pydebug module. Open C:\Program Files\QGIS 3.32.2\OSGeo4W.bat and call:
pip3 install debugpy pip3 install pyqt5-stubs # not neccesary
-
Open VSCode. Locate to plugin folder
-
press "Ctrl-Shift-P" and type ">preferences: Open Workspace Settings (JSON)"
-
Open "./.vscode/settings.json" file and add the following lines (Change qgis and python versions if needed)
{ "python.defaultInterpreterPath": "C:\\Program Files\\QGIS 3.32.2\\apps\\Python39\\python.exe", "python.autoComplete.extraPaths": [ "C:\\Program Files\\QGIS 3.32.2\\apps\\qgis\\python" ], "python.analysis.extraPaths": [ "C:\\Program Files\\QGIS 3.32.2\\apps\\qgis\\python" ] }
-
Click on "Run and debug" button -> "create launch.json file"
-
Choose python -> select "Remote Attach"
-
The launch file must looks like:
{ // 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: Remote Attach", "type": "python", "request": "attach", "connect": { "host": "localhost", "port": 5678 }, "justMyCode": true } ] }