After I have installed QGIS from OSGeo4w and added some enviroment of GDAL to the system path on my windows 10 computer, I get some error information from SNAP GPT command line, like below:
INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters
ERROR 1: Can’t load requested DLL: C:\OSGeo4W64\bin\gdalplugins\gdal_ECW_JP2ECW.dll
126: can not find module
ERROR 1: Can’t load requested DLL: C:\OSGeo4W64\bin\gdalplugins\ogr_SOSI.dll
126: can not find module
However, the gpt program seems still work on (for processing sentinel-1), and I get the anticipated result map as usual. But I am not sure whethere there is some process failed. The error infomation exists even after I have removed all the environment related to GDAL from the system path (I have not restart the computer).
I have checked that gdal used by the snap seems to be included in the “s2tbx.properties” file as below,
I have added GDAL_DATA, GDAL_DRIVER_PATH, PYTHON, PROJ_LIB et al to the system environment in order to use the QGIS module standlone from python.
Sorry for post this question in a hurry. Now I have fixed the problem by removing all the environment and restart the computer. It is better do this by temperally change the environment in the python environment.
You can put some code to your Python launcher or even at the beginning of your code (e.g. as a separate function “import-paths”) to include these directories.
C:\ProgramData\Anaconda3\envs\mysnap\Lib\site-packages\osgeo
Then I run the code by using: python filename.py
I got below error:
ERROR 1: Can’t load requested DLL: C:\ProgramData\Anaconda3\envs\mysnap\lib\site-packages\osgeo\gdalplugins\ogr_FileGDB.dll 126: The specified module could not be found.
ERROR 1: Can’t load requested DLL: C:\ProgramData\Anaconda3\envs\mysnap\lib\site-packages\osgeo\gdalplugins\ogr_FileGDB.dll 126: The specified module could not be found.
I tried to import the dll directly by following codes based on your suggestion here:
Traceback (most recent call last):
File “main.py”, line 5, in
dll=ctypes.WinDLL(“C:\ProgramData\Anaconda3\envs\mysnap\Lib\site-packages\osgeo\gdalplugins\ogr_FileGDB.dll”)
File “C:\ProgramData\Anaconda3\envs\mysnap\lib\ctypes_init_.py”, line 366, in init
When using GDAL libraries with python they need to be built with the same compiler that was used for python. This is a common problem on Windows as many different compilers are used (Microsoft cc, GNU gcc, Intel icc, clang). If you are using Anaconda Python you should look for a suitable GDAL package from Anaconda or conda-forge. Linux is usually simpler as most packages use GNU gcc. For Windows 10, WSL2 allows you to use linux for command-line processing.