1

I download GDAL 3.3.2(with compiler MSVC 2019) from here. I have downloaded the following components and install them in windows 10 x64:

  • gdal-303-1928-x64-core.msi
  • GDAL-3.3.2.win-amd64-py3.9.msi
  • gdal-303-1928-x64-mrsid.msi
  • gdal-303-1928-x64-ecw-55.msi
  • and python-3.9.7-amd64

The environment variables are as the follow:

  • GDAL_DATA = C:\Program Files\GDAL\gdal-data
  • GDAL_DRIVER_PATH = C:\Program Files\GDAL\gdalplugins
  • USE_PATH_FOR_GDAL_PYTHON = YES
  • path = ...;C:\Program Files\GDAL;

When I run gdal2tiles.py -z 12-13 sample.tif /tiles the output is as follow:

ERROR 1: Can't load requested DLL: C:\Program Files\GDAL\gdalplugins\gdal_GEOR.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\GDAL\gdalplugins\gdal_GEOR.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\GDAL\gdalplugins\gdal_MrSID.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\GDAL\gdalplugins\gdal_MrSID.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\GDAL\gdalplugins\ogr_MSSQLSpatial.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\GDAL\gdalplugins\ogr_MSSQLSpatial.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\GDAL\gdalplugins\ogr_OCI.dll
126: The specified module could not be found.

ERROR 1: Can't load requested DLL: C:\Program Files\GDAL\gdalplugins\ogr_OCI.dll
126: The specified module could not be found.

Traceback (most recent call last):
  File "C:\Program Files\GDAL\gdal2tiles.py", line 5, in <module>
    from osgeo_utils.gdal2tiles import *  # noqa
  File "C:\Users\Internet\AppData\Local\Programs\Python\Python39\lib\site-packages\osgeo_utils\gdal2tiles.py", line 58, in <module>
    from osgeo import gdal
  File "C:\Users\Internet\AppData\Local\Programs\Python\Python39\lib\site-packages\osgeo\gdal.py", line 1920, in <module>
    import ogr
ModuleNotFoundError: No module named 'ogr'

In C:\Program Files\GDAL\gdalplugins\ exist all gdal_GEOR.dll, gdal_MrSID.dll, ogr_MSSQLSpatial.dll, ogr_OCI.dll files, and In C:\Program Files\GDAL exist the gdal2tiles.py file. What's the problem?

9
  • Are you able to run some of the other GDAL programs? At the command line try ogrinfo --version
    – GreyHippo
    Oct 19, 2021 at 19:08
  • @GreyHippo the result is ERROR 1: Can't load requested DLL: C:\Program Files\GDAL\gdalplugins\gdal_MrSID.dll ... GDAL 3.3.2, released 2021/09/01 Oct 20, 2021 at 5:53
  • would you be willing to try a different way of installing gdal? (e.g in an python environment) Or are you specifically looking for a way for solving this case? Oct 21, 2021 at 9:42
  • @JaschaMuller The windows server does not have Internet, so I have to install GDAL with installer files Oct 21, 2021 at 11:29
  • Ok, that makes it a bit more challenging. I would have recommended to download the gdal wheel file from here lfd.uci.edu/~gohlke/pythonlibs according to your version of python you have installed on the server and then pip install the wheel (but I am unsure if you still need an internet connection to pip install a local file). Oct 21, 2021 at 13:41

2 Answers 2

6
+50

EDIT

There is actually an open ticket from August, 2021 about this problem in the issue tracker https://github.com/gisinternals/buildsystem/issues/180

The Python modules that gisinternals.com deliver are not up to date. The error messages in your question are showing where the error happens. For example this one that refers to line 1920 in file gdal.py

 import ogr
ModuleNotFoundError: No module named 'ogr'

The GDAL Python API documentation in https://gdal.org/api/python.html gives information about imports.

There are five major modules that are included with the GDAL Python bindings.:

>>> from osgeo import gdal
>>> from osgeo import ogr
>>> from osgeo import osr
>>> from osgeo import gdal_array
>>> from osgeo import gdalconst

Additionally, there are five compatibility modules that are included
but provide notices to state that they are deprecated and will be going
away. If you are using GDAL 1.7 bindings, you should update your imports
to utilize the usage above, **but the following will work until GDAL 3.1.**

>>> import gdal
>>> import ogr
>>> import osr
>>> import gdalnumeric
>>> import gdalconst

The Python bindings of gisinternals.com are not up to date and they cannot work with GDAL version 3.2 and higher without a fix. It may be possible to get a bit further by editing the lines that give errors

import ogr -> import osgeo.ogr

There is one place to edit in ogr.py and two in gdal.py. After those edits the gdal2tiles.py script at least starts but I did not make any tests with data.

However, there are warnigns in the headers of the .py files

# This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.2
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.

You could also have a try with GDAL 3.1 or older from the archive https://gisinternals.com/archive.php. They may not suffer from this import issue. On the other hand, by the comment in the issue tracker the Python bindings may have problems with all Python 3 builds.

1
0
from osgeo import gdal,ogr

You need to download osgeo module.

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.