Also, ich sollte nicht beschweren, aber es ist ärgerlich. Auf meinem Setup (Windows Server 2012 R2) importieren GDAL in Python in den Terminal druckt die folgenden:Importieren von GDAL druckt viele Fehlermeldungen, aber funktioniert immer noch
>>> 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.
>>>
Aber ich kann immer noch GDAL ohne Probleme, trotz dieser Nachrichten. In Jupyter werden diese Fehler nicht gedruckt. Für mich sind solche Nachrichten egal, solange die Funktionalität nicht bricht und für meinen Anwendungsfall nicht. Ich rufe jedoch die Funktion, die GDAL mit multiprocessing Pool
importiert, auf 12 Kernen, und es druckt das unnötig 12 Mal aus. Das nervt vor allem, weil es die Ausgabe verunstaltet, an der ich interessiert bin: Ausführungsfortschritt. Was kann ich dagegen tun (entweder um diese Nachrichten auszublenden oder um die zugrunde liegenden Probleme zu beheben, die sie verursachen)?
Hinweis, Python-Version ist: Python 3.5.1 | Anaconda benutzerdefinierte (64-Bit) | (Standard, 16. Februar 2016, 09:49:46) [MSC gegen 1900 64 Bit (AMD64)] auf win32. GDAL wird offensichtlich von Anaconda aus vom IOOS-Custom-Package installiert. Die GDAL-Version ist 1.11.4, np110py35_vc14_7.
Haben Sie versucht, das [Protokollierungsmodul zum Erfassen von Warnungen] (https://docs.python.org/3/library/logging.html#logging.captureWarnings) zu verwenden? Bevor Sie importieren: 'Import Logging; logging.captureWarnings (Wahr); Import von Gdal; logging.captureWarnings (Falsch) '. Das könnte sie davor bewahren, auf stderr zu drucken. –
Ich habe alles versucht, direkt von der Umleitung der Konsole auf die Verwendung von Paketen, um Warnungen zu ignorieren. Obwohl ich Ihre spezielle Lösung nicht versucht habe, würde ich mir vorstellen, dass es nicht funktionieren wird. Es ist nicht Python, das die GDAL-Nachrichten druckt, sondern GDAL selbst. Diese Warnungen kommen aus dem C-Code von GDAL, in einer Weise, die nicht durch die Python-GDAL-Bindungen geleitet wird. Also nichts aus Python wird den Trick machen, es ist eine GDAL-Konfigurationseinstellung, die geändert werden muss. Ich weiß nicht, wie das geht. – Kartik
Außerdem war ich Praktikant in einer Firma, wo mein Projekt GDAL verwendete. Seit dem Abschluss dieses Praktikums arbeite ich nicht mehr mit GDAL oder habe Zugang zum Unternehmen, um Ihre Lösung auszuprobieren. Aber wenn jemand anderes GDAL benutzt und ähnliche Probleme hat, kann diese Person von Ihrer Lösung profitieren und kann kommentieren, um uns mitzuteilen, wie es funktioniert. – Kartik