导入GDAL会打印大量错误消息,但仍可正常运行

时间:2016-07-27 00:17:43

标签: python python-3.x gdal

所以,我不应该抱怨,但这很烦人。在我的设置(Windows Server 2012 R2)中,在终端中用Python导入GDAL会打印以下内容:

>>> 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.

>>>

但我仍然可以毫无问题地使用GDAL,尽管有这些消息。在Jupyter中,不会打印这些错误。本身,只要功能不破坏,我就不关心这些消息,对于我的用例,它不会。但是,我在12个核心上调用使用multiprocessing Pool导入GDAL的函数,并且它不必要地打印了12次。这很烦人,主要是因为它模糊了我感兴趣的输出:执行进度。我能做些什么(隐藏这些消息或解决导致它们出现的潜在问题的方法)?

注意,Python版本是:Python 3.5.1 | Anaconda自定义(64位)| (默认情况下,2016年2月16日,09:49:46)[MSC版本1900 64位(AMD64)]在win32上。 GDAL显然是从Anaconda安装的,来自IOOS定制包。 GDAL版本为1.11.4,np110py35_vc14_7。

2 个答案:

答案 0 :(得分:2)

查看the source,您可以看到它尝试在try / except块中导入模块。它将打印GDAL错误但不会引发Python异常,除非使用gdal.UseExceptions()启用该模式。

某些功能/功能很可能会出错,但您根本就没有在脚本中使用它们。具体来说,它正在寻找HDF和其他格式的一些驱动程序。编译OSGEO / GDAL可能存在问题,因为对某些格式的支持需要特殊构建。

如果您确实需要对这些格式的支持,您应该重新正确构建,或者重新开始使用新的"普通"安装。

答案 1 :(得分:2)

我遇到了类似的问题。我在 Windows 上设置了 GDAL_DRIVER_PATH 变量,这导致了这个日志/错误。我假设它来自我之前安装的 GDAL 并且仍然指向错误的目录。