I am trying to set up QGIS3 and python so I can write a script that uses GDAL- I want to do this from the OSGEO4W shell. I have read a lot of questions and followed some tutorials which led me to do this once installing the software:

Firstly I load this cmd which works without error in the OSGEO4W shell:

@echo off
call "%OSGEO4W_ROOT%"\bin\o4w_env.bat

@echo off
path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;%OSGEO4W_ROOT%\apps\Qt5\bin
path %PATH%;%OSGEO4W_ROOT%\apps\Python36\Scripts

set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python36
set PATH=C:\Users\Issy\Documents\QGIS;%PATH%

Then there is the issue:


Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit 
(AMD64)] on win32

import qgis.core

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\OSGeo4W64\apps\qgis\python\qgis\core\__init__.py", line 27, in ><module>
    from qgis._core import *
ImportError: DLL load failed: The specified procedure could not be found.

I have tried numerous pythonpath settings and installed/re-installed with different settings but I just can't get this to work.

  • There is a template for a batch file to call python from the osgeo4w shell in bin. Rename it by removing the tmpl-extension. Also, to use gdal, you don't need the qgis module, just import gdal. Commented Aug 16, 2018 at 22:17

1 Answer 1


I had similar problem stated above. I want use not only GDAL but QGIS. This is the content of my .bat file (located in C:\OSGeo4W64):

**@echo off


call "%OSGEO4W_ROOT%"\bin\o4w_env.bat

call "%OSGEO4W_ROOT%"\apps\grass\grass-7.4.1\etc\env.bat

path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin

path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass-7.4.1\lib

path %PATH%;C:\OSGeo4W64\apps\Qt5\bin

path %PATH%;C:\OSGeo4W64\apps\Python37\Scripts


set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python37

set PATH=C:\Program Files\Git\bin;%PATH%


Firstly, it worked on one computer but on the other not (both Windows 10): enter image description here

Difference: during installation (the other) enter image description here


  1. Uninstall OSGeo4W64

  2. Chceck Windows updates

  3. Uninstall old versions of Microsoft Visual C++ Redistributable Package

  4. Install: Microsoft Visual C++ 2010 Redistributable Package (x64)

  5. Install: Windows 10 Universal C Runtime

  6. Install OSGeo4W64 (advanced install>>check:

enter image description here

and next window chceck to install the rest of recommended packages.

It works. Maybe it'll help somebody.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.