Skip to content

Instantly share code, notes, and snippets.

Debugging QGIS 3.x python plugins on Ubuntu 22.04 using VS Code

My setup uses Ubuntu 22.04 running on Windows WSL2, which suppots executing GUI applications.

Setting up VS Code

NOTE: I'm using VS Code Python Debugger extension version v2024.12.0 (ms-python.debugpy), which uses debugpy.

QGIS

In my setup I'm running QGIS built from source, following the official instructions. My build is under /home/giohappy/dev/qgis/QGIS/build.

A generic version built on top of https://gist.github.com/giohappy/8a30f14678aa7e446f9b694c632d7089

Debugging QGIS 3.x python plugins on Windows 11 using VS Code

Setting up VS Code

NOTE: I'm using VS Code Python Debugger extension version v2024.10.0 (ms-python.debugpy), which uses debugpy.

Start VS Code

For simplicity I start VS Code directly from the plugin folder. We could symlink to avoid polluting the folder with out configurations...

@giohappy
giohappy / gist:8a30f14678aa7e446f9b694c632d7089
Last active March 7, 2024 15:47
QGIS Python plugin debuggin with VS Code on Windows

A debugpy version inspired by this gist: https://gist.github.com/NicolaiMogensen/acfd8723720c4761aefef3cdfc2aa55a

Debugging QGIS 3.x python plugins on Windows 11 using VS Code

Setting up VS Code

NOTE: I'm using VS Code Python extension version 2022.20.2, which has PyLance as language server. The most recent versions of the extension use debugpy debugger.

Start VS Code

For simplicity I start VS Code directly from the plugin folder.

@giohappy
giohappy / gwc_layer_config.py
Last active July 5, 2022 13:42
Configure GWC caching for all Geoserver layers
import requests
import json
REQ_TEMPLATE = '''<?xml version="1.0" encoding="UTF-8"?>
<GeoServerLayer>
<enabled>true</enabled>
<inMemoryCached>true</inMemoryCached>
<name>{}</name>
<metaWidthHeight>
<int>2</int>
@giohappy
giohappy / deploy-geoserver
Created June 21, 2021 20:05
Install GeoServer on cloud server with Ubuntu 20.04
# Install GeoServer on cloud server
________________
## 1. Install Java JDK
apt install openjdk-11-jdk
You can check the installation using `$ java -version`. Now you can see something like this:
openjdk version "11.0.7" 2020-04-14
@giohappy
giohappy / export_env_file.sh
Last active June 7, 2021 11:23
Export env file bash script
#source ./export_env_file.sh ./.env
set -o allexport
. $1
set +o allexport
@giohappy
giohappy / tmux.cheat
Created April 24, 2018 17:50 — forked from afair/tmux.cheat
Tmux Quick Reference & Cheat sheet - 2 column format for less scrolling!
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

# data test for PostGIS BRIN Indexes
# a small dataset ( ~400K rows for roads)
wget http://download.geofabrik.de/europe/france/bretagne-latest.shp.zip
unzip bretagne-latest.shp.zip
shp2pgsql -s 4326:2154 -I landuse.shp landuse | psql -h localhost -p 32770 -U pggis -d pggis
shp2pgsql -s 4326:2154 -I natural.shp natural | psql -h localhost -p 32770 -U pggis -d pggis
shp2pgsql -s 4326:2154 -I places.shp places | psql -h localhost -p 32770 -U pggis -d pggis
shp2pgsql -s 4326:2154 -I points.shp points | psql -h localhost -p 32770 -U pggis -d pggis
@giohappy
giohappy / mvt.html
Last active October 23, 2017 10:08
Flask + OL MVT vector layer
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>MVT</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/ol.css') }}">
</head>
<body>
<div id="map"class="map"></div>
<script src="{{ url_for('static', filename='js/ol-debug.js') }}"></script>