unable to open qgis with standalone script

36 views Asked by At

after almost 2 hours of debugging I`m still unable to figure out what is the problem.

I have this .bat

echo on
cls
echo ___________________________
echo wait some secs...
SET GDAL_DATA=C:\Program Files\QGIS 3.16\share\gdal
SET GDAL_DRIVER_PATH=C:\Program Files\QGIS 3.16\bin\gdalplugins
SET GDAL_FILENAME_IS_UTF8=YES
SET GEOTIFF_CSV=C:\Program Files\QGIS 3.16\share\epsg_csv
SET O4W_QT_BINARIES=C:/Program Files/QGIS 3.16/apps/Qt5/bin
SET O4W_QT_DOC=C:/Program Files/QGIS 3.16/apps/Qt5/doc
SET O4W_QT_HEADERS=C:/Program Files/QGIS 3.16/apps/Qt5/include
SET O4W_QT_LIBRARIES=C:/Program Files/QGIS 3.16/apps/Qt5/lib
SET O4W_QT_PLUGINS=C:/Program Files/QGIS 3.16/apps/Qt5/plugins
SET O4W_QT_PREFIX=C:/Program Files/QGIS 3.16/apps/Qt5
SET O4W_QT_TRANSLATIONS=C:/Program Files/QGIS 3.16/apps/Qt5/translations
SET OSGEO4W_ROOT=C:\Program Files\QGIS 3.16
SET Path=C:\Program Files\QGIS 3.16\apps\qgis-ltr\bin;C:\Program Files\QGIS 3.16\apps\Python37;C:\Program Files\QGIS 3.16\apps\Python37\Scripts;C:\Program Files\QGIS 3.16\apps\qt5\bin;C:\Program Files\QGIS 3.16\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32\WBem
SET PROJ_LIB=C:\Program Files\QGIS 3.16\share\proj
SET PYTHONHOME=C:\Program Files\QGIS 3.16\apps\Python37
SET PYTHONPATH=C:\PROGRA~1\QGIS3~1.16\apps\Python37;C:\PROGRA~1\QGIS3~1.16\apps\Python37\Scripts
SET QGIS_PREFIX_PATH=C:/Program Files/QGIS 3.16/apps/qgis-ltr
SET QT_PLUGIN_PATH=C:\Program Files\QGIS 3.16\apps\qgis-ltr\qtplugins;C:\Program Files\QGIS 3.16\apps\qt5\plugins

REM   %1 = source python script


python %1

my .py

import sys
import os

sys.path.append('C:\\Program Files\\QGIS 3.16\\apps\\qgis-ltr\\python')
sys.path.append('C:\\Program Files\\QGIS 3.16\\apps\\qgis-ltr\\python\plugins')

from qgis.core import *
from qgis.gui import QgsMapCanvas, QgsLayerTreeMapCanvasBridge

qgs = QgsApplication([], True)
qgs.initQgis()

which should start a Qgis UI interface instance.

if i do some processing with qgis in this script how can I open an instance of the UI and load what I computed in the script.

0

There are 0 answers