1

I want to create a simple hillshade image using pyqgis standalone app but any time to try it to run my app then I take error :

Process finished with exit code -1073740940 (0xC0000374)

my system details :

windows 10 64 bit,qgis install via osgeo4w64 64 bit latest version,pycharm 64 bit

here my .bat file :

@echo off
SET OSGEO4W_ROOT=C:\OSGeo4W64
call "%OSGEO4W_ROOT%"\bin\o4w_env.bat
call "%OSGEO4W_ROOT%"\apps\grass\grass-7.2.1\etc\env.bat
@echo off
path %PATH%;%OSGEO4W_ROOT%\apps\qgis-ltr-dev\bin;%OSGEO4W_ROOT%\apps\grass\grass-7.2.1\lib
set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:\=/%/apps/qgis-ltr-dev
SET PYCHARM="C:\Program Files\JetBrains\PyCharm 2017.1.5\bin\pycharm64.exe"
set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis-ltr-dev\python;
set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\Python27\Lib\site-packages;
set QGISPATH=%OSGEO4W_ROOT%\apps\qgis-ltr-d
start "PyCharm aware of QGIS" /B %PYCHARM% %*

here the pyqgis script :

from qgis.core import QgsApplication
from qgis.core import *
from PyQt4.QtGui import QApplication
app = QApplication([])
QgsApplication.setPrefixPath('C:/OSGeo4W64/apps/qgis-ltr-dev', True)
QgsApplication.initQgis()
sys.path.append('C:/OSGeo4W64/apps/qgis-ltr-dev/python/plugins')
from processing.core.Processing import Processing
import processing
Processing.initialize()
rasterLyr=QgsRasterLayer('C:/mypath/dem.tif','hillshade')
rasterLyr.isValid()
processing.runalg('gdalogr:hillshade',rasterLyr,1.0,False,False,1.0,1.0,315.0,45.0,'C:/mypath/hill.tif')
QgsApplication.exitQgis()
QApplication.exit()

here the error message in pycharm :

traceback:  File "C:/Users/username/PycharmProjects/untitled/tda.py", line 10, in <module>
    import processing
  File "C:\OSGeo4W64\apps\qgis-ltr-dev\python\plugins\processing\__init__.py", line 29, in <module>
    from processing.tools.general import *
  File "C:\OSGEO4~1\apps\qgis-ltr-dev\python\qgis\utils.py", line 572, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\OSGeo4W64\apps\qgis-ltr-dev\python\plugins\processing\tools\general.py", line 28, in <module>
    from processing.core.Processing import Processing
  File "C:\OSGEO4~1\apps\qgis-ltr-dev\python\qgis\utils.py", line 572, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\OSGeo4W64\apps\qgis-ltr-dev\python\plugins\processing\core\Processing.py", line 42, in <module>
    from processing.gui.MessageBarProgress import MessageBarProgress
  File "C:\OSGEO4~1\apps\qgis-ltr-dev\python\qgis\utils.py", line 572, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\OSGeo4W64\apps\qgis-ltr-dev\python\plugins\processing\gui\MessageBarProgress.py", line 34, in <module>
    from processing.gui.MessageDialog import MessageDialog
  File "C:\OSGEO4~1\apps\qgis-ltr-dev\python\qgis\utils.py", line 572, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "C:\OSGeo4W64\apps\qgis-ltr-dev\python\plugins\processing\gui\MessageDialog.py", line 38, in <module>
    os.path.join(pluginPath, 'ui', 'DlgMessage.ui'))
  File "C:\OSGEO4~1\apps\Python27\Lib\site-packages\PyQt4\uic\__init__.py", line 210, in loadUiType
    winfo = compiler.UICompiler().compileUi(uifile, code_string, from_imports, resource_suffix)
  File "C:\OSGEO4~1\apps\Python27\Lib\site-packages\PyQt4\uic\Compiler\compiler.py", line 139, in compileUi
    w = self.parse(input_stream, resource_suffix)
  File "C:\OSGEO4~1\apps\Python27\Lib\site-packages\PyQt4\uic\uiparser.py", line 933, in parse
    actor(elem)
  File "C:\OSGEO4~1\apps\Python27\Lib\site-packages\PyQt4\uic\uiparser.py", line 844, in readResources
    for include in elem.getiterator("include"):

...

src\core\qgsproviderregistry.cpp():(QgsProviderRegistry:init)CheckingC:/OSGeo4W64/apps/qgis-ltr-dev/plugins for provider plugins
    src\core\qgsproviderregistry.cpp():(QgsProviderRegistry:init)[]CheckingC:/OSGeo4W64/apps/qgis-ltr-dev/plugins/basicauthmethod.dll:invalid(no isProvider method)
    src\core\qgsproviderregistry.cpp():(QgsProviderRegistry:init)[]CheckingC:/OSGeo4W64/apps/qgis-ltr-dev/plugins/coordinatecaptureplugin.dll:invalid(has type method)
    src\core\qgsproviderregistry.cpp():(QgsProviderRegistry:init)[ms]CheckingC:/OSGeo4W64/apps/qgis-ltr-dev/plugins/dxf2shpconverterplugin.dll:invalid(has type method)

...

    src\core\qgsproviderregistry.cpp():(QgsProviderRegistry:clean)[]cleanup:postgres
    src\core\qgsproviderregistry.cpp():(QgsProviderRegistry:clean)[]cleanup:spatialite
    src\core\qgsproviderregistry.cpp():(QgsProviderRegistry:clean)[]cleanup:virtual
    src\core\qgsproviderregistry.cpp():(QgsProviderRegistry:clean)[]cleanup:wcs
    src\core\qgsproviderregistry.cpp():(QgsProviderRegistry:clean)[]cleanup:wms
    src\providers\gdal\qgsgdalprovider.cpp():(QgsGdalProvider::QgsGdalProvider)[]entering.

    Process finished with exit code -1073740940 (0xC0000374)

I have remove some lines because is to long message

if I change 'C:/OSGeo4W64/apps/qgis-ltr-dev' to 'C:/OSGeo4W64/apps/qgis-rel-dev' in .bat file and in my script I take some error message.

if I use this 'C:/OSGeo4W64/apps/qgis-ltr' or 'C:/OSGeo4W64/apps/qgis' in my .bat file and in my script then just I take

Process finished with exit code -1073740940 (0xC0000374)

any idea why ?

more Unexpectedly thing is the my export hill.tif created correct but script crashed....what I have wrong ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.