From c986d7668a2a13c63122fce91c0b40828a7f6896 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Thu, 29 Aug 2024 12:42:58 +0200 Subject: [PATCH] Only require `qgis.gui` import when gui is built --- src/python/qgspythonutilsimpl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/python/qgspythonutilsimpl.cpp b/src/python/qgspythonutilsimpl.cpp index 14a79ec87c66..1ed26dac8ebd 100644 --- a/src/python/qgspythonutilsimpl.cpp +++ b/src/python/qgspythonutilsimpl.cpp @@ -159,7 +159,11 @@ def run_startup_script(script_path): // import QGIS bindings QString error_msg = QObject::tr( "Couldn't load PyQGIS." ) + '\n' + QObject::tr( "Python support will be disabled." ); - if ( !runString( QStringLiteral( "from qgis.core import *" ), error_msg ) || !runString( QStringLiteral( "from qgis.gui import *" ), error_msg ) ) + if ( !runString( QStringLiteral( "from qgis.core import *" ), error_msg ) +#ifdef HAVE_GUI + || !runString( QStringLiteral( "from qgis.gui import *" ), error_msg ) +#endif + ) { return false; }