Importing GDAL prints lots of error messages, but still works

时光毁灭记忆、已成空白 提交于 2019-12-23 09:01:20

问题


So, I should not be complaining, but it is annoying. On my setup (Windows Server 2012 R2) importing GDAL in Python in the 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 those messages. In Jupyter, those errors are not printed. Per se, I don't care about those messages as long as functionality does not break, and for my usecase, it does not. However, I am calling the function that imports GDAL using multiprocessing Pool, on 12 cores, and it prints that out needlessly 12 times. That gets annoying mainly because it obscures the output I am interested in: execution progress. What can I do about this (either a way to hide these messages, or resolve the underlying issues that cause them to appear)?

Note, Python version is: Python 3.5.1 |Anaconda custom (64-bit)| (default, Feb 16 2016, 09:49:46) [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.


回答1:


Looking at the source, you can see that it tries to import modules in a try/except block. It will print GDAL errors but will not raise Python exceptions, unless that mode is enabled with gdal.UseExceptions().

It is likely that certain functions / functionality would error out but that you are simply not making use of them in your scripts. Specifically, it is looking for some drivers for HDF and other formats. There may have been an issue compiling OSGEO/GDAL since support for some of these formats requires special builds.

You should either re-build correctly if you do need support for these formats, or start again with a fresh "plain" install.



来源:https://stackoverflow.com/questions/38601836/importing-gdal-prints-lots-of-error-messages-but-still-works

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!