GDAL Python bindings crash when calling gdal.Translate/gdal.Warp synchronously in PyQt5 GUI
I’m experiencing a hard crash (process terminates immediately, no Python exception) whenever I run GDAL operations like gdal.Translate or gdal.Warp synchronously in the main thread of a PyQt5 application.
The same GDAL code works perfectly outside the PyQt environment. This seems specific to running GDAL operations inside the GUI thread on Windows 11.
Environment
*
PyQt5
*
GDAL 3.10.1 (Python wheel)
*
Python 3.13.3
*
Windows 11
Minimal Reproducible Example
# main.py
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton
from PyQt5.QtCore import QTimer
from osgeo import gdal
class Geo:
def __init__(self, input_path, output_path):
gdal.UseExceptions() # enable exceptions
self.input_path = input_path
self.output_path = output_path
def run(self):
ds = gdal.Open(self.input_path, gdal.GA_ReadOnly)
try:
gdal.Translate(self.output_path, ds)
# gdal.Warp(...) # also causes crash
finally:
del ds
class GeoGUI(QMainWindow):
def __init__(self):
super().__init__()
btn = QPushButton("Run GDAL", self)
btn.clicked.connect(self.on_run_button_clicked)
self.setCentralWidget(btn)
def on_run_button_clicked(self):
geo = Geo("input.tif", "output.tif")
geo.run() #