导入GDAL会打印很多错误消息,但仍然可以使用 [英] Importing GDAL prints lots of error messages, but still works

查看:301
本文介绍了导入GDAL会打印很多错误消息,但仍然可以使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我不应该抱怨,但这很烦人.在我的安装程序(Windows Server 2012 R2)中,在终端中以Python导入GDAL会显示以下内容:

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.

>>>

但是,尽管有这些消息,我仍然可以毫无问题地使用GDAL.在Jupyter中,不会打印这些错误.就本质而言,只要功能没有中断,我就不在乎这些消息,而对于我的用例,则不会.但是,我在12个内核上调用了使用multiprocessing Pool导入GDAL的函数,它不必要地打印了12次.这之所以令人讨厌,主要是因为它模糊了我感兴趣的输出:执行进度.我该怎么办(隐藏这些消息或解决导致它们出现的潜在问题)?

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)?

注意,Python版本是:Python 3.5.1 | Anaconda自定义(64位)| (默认值,2016年2月16日,09:49:46)在Win32上的[MSC v.1900 64位(AMD64)].显然,GDAL是从Anaconda的IOOS自定义软件包中安装的. GDAL版本为1.11.4,np110py35_vc14_7.

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.

推荐答案

查看

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

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

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.

这篇关于导入GDAL会打印很多错误消息,但仍然可以使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆