I have a python script (as given below) in QGIS which will just print "Hello QGIS!".
import sys from qgis.core import * # Initialize QGIS Application QgsApplication.setPrefixPath("C:/OSGeo4W/apps/qgis", True) app = QgsApplication([], True) QgsApplication.initQgis() # Add the path to Processing framework sys.path.append('C:/OSGeo4W/apps/qgis/plugins') # Import and initialize Processing framework from processing.core.Processing import Processing Processing.initialize() import processing print 'Hello QGIS!' Now, I want to execute this python script without opening QGIS by using a Windows Batch File script. The .bat file which I created for this is given below.
REM Change OSGEO4W_ROOT to point to the base install folder set QGIS_PREFIX_PATH=C:\OSGeo4W\apps\qgis REM Gdal Setup set GDAL_DATA=C:\OSGeo4W\share\gdal\ REM Python Setup set PATH=C:\OSGeo4W\bin;C:\OSGeo4W\apps\qgis\bin;%PATH% SET PYTHONHOME=C:\OSGeo4W\apps\Python27 set PYTHONPATH=C:\OSGeo4W\apps\qgis\python;%PYTHONPATH% REM Launch python job python C:/Users/Sreeraj/.qgis2/processing/scripts/hello.py pause Unfortunately, I am getting an error :
File "C:/Users/Sreeraj/.qgis2/processing/scripts/hello.py", line 13, in <module> from processing.core.Processing import Processing ImportError: No module named processing.core.Processing I also tried modifying the .bat file as given below.
SET QGIS_PREFIX_PATH=C:\OSGeo4W\apps\qgis call "C:/OSGeo4W/bin/o4w_env.bat" SET PYTHONPATH=C:\OSGeo4W\apps\qgis\python;%PYTHONPATH% SET PATH=%PATH%;C:\OSGeo4W\apps\qgis\bin cmd /c python "C:/Users/Sreeraj/.qgis2/processing/scripts/hello.py" Again, I am getting the same error :
ImportError: No module named processing.core.Processing But, clearly, I have set everything correctly and the processing folder is located in C:/Users/Sreeraj/.qgis2/ .
So, what kind of modification do I have to make in order to run this basic python script correctly using a .bat file ?
import processingwithfrom processing.tools import *.