GDAL import prints a lot of error messages, but still works

So, I should not complain, but it is annoying. In my setup (Windows Server 2012 R2), importing GDAL into Python in a terminal prints the following:

>>> import gdal ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ BAG.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ BAG.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ FITS.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ FITS.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ GMT.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ GMT.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ HDF4.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ HDF4.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ HDF4Image.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ HDF4Image.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ HDF5.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ HDF5.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ HDF5Image.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ HDF5Image.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ netCDF.dll 193: %1 is not a valid Win32 application. ERROR 1: Can't load requested DLL: C:\Program Files (x86)\GDAL\gdalplugins\gdal_ netCDF.dll 193: %1 is not a valid Win32 application. >>> 

But I can still use GDAL without any problems, despite these messages. Jupyter does not print these errors. In fact, I do not care about those messages until the functionality breaks, but for my utility this is not so. However, I call a function that imports GDAL using the multiprocessing Pool , on 12 cores, and it outputs it unnecessarily 12 times. This is annoying, mainly because it overshadows the conclusion that interests me: the progress. What can I do about this (a way to hide these messages or fix the main problems that cause them to appear)?

Note. Python Version: Python 3.5.1 | Anaconda custom (64-bit) | (default, February 16, 2016 09:49:46 AM) [MSC v. 1900 64 bit (AMD64)] on win32. GDAL is obviously installed from Anaconda from the IOOS custom package. GDAL version is 1.11.4, np110py35_vc14_7.

+6
source share
1 answer

Looking at the source , you can see that it is trying to import the modules into a try / except block. It will print GDAL errors, but will not throw Python exceptions if this mode is not enabled using gdal.UseExceptions() .

It is likely that some functions / functions will fail, but you simply do not use them in your scripts. In particular, he is looking for some drivers for HDF and other formats. There may be a problem compiling OSGEO / GDAL, since support for some of these formats requires special builds.

You must either build correctly if you need support for these formats, or start with a new β€œsimple” installation.

+1
source

All Articles