Ultimately I'm attempting to launch the QGIS GUI and run a python script from a batch file. I've reviewed numerous instances referencing similar scenarios on this and other forums but for the life of me I can't get it to work.
My batch file code is:
@echo off
SET OSGEO4W_ROOT=C:\Program Files\QGIS 3.4
call "C:\Program Files\QGIS 3.4\bin\o4w_env.bat"
call "C:\Program Files\QGIS 3.4\bin\qt5_env.bat"
call "C:\Program Files\QGIS 3.4\bin\py3_env.bat"
@echo off
path %OSGEO4W_ROOT%\apps\qgis\bin;%PATH%
set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:\=/%/apps/qgis
set GDAL_FILENAME_IS_UTF8=YES
rem Set VSI cache to be used as buffer, see #6448
set VSI_CACHE=TRUE
set VSI_CACHE_SIZE=1000000
set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\qgis\qtplugins;%OSGEO4W_ROOT%\apps\qt5\plugins
set PYTHONPATH=%OSGEO4W_ROOT%\apps\qgis\python;%PYTHONPATH%
python C:\temp\test.py
pause
My python script is:
import sys
from qgis.core import *
# Initialize QGIS Application
QgsApplication.setPrefixPath("C:\Program Files\QGIS 3.4\apps\qgis", True)
app = QgsApplication([], True)
QgsApplication.initQgis()
# Add the path to Processing framework
sys.path.append('C:\Program Files\QGIS 3.4\apps\qgis\python\plugins')
# Import and initialize Processing framework
from processing.core.Processing import Processing
Processing.initialize()
import processing
print('Hello QGIS!')
Currently this code fails with the following message:
If I remove the importing of the processing framework section of the py script then 'Hello QGIS!' is printed in the batch window but the GUI does not launch.
Where am I going wrong?