gdal
-
I want to call a Python program from Qt. In my Python script, I need to use the third-party library osgeo. The gdal module works fine, but when I try to import gdal_array, I get the following error:
Traceback (most recent call last):
File "D:\code/c_cpp/LAIsoftware/laisoftware\HLSPY.py", line 433, in check
arr = ds.GetRasterBand(1).ReadAsArray()
File "D:\codetool\mambaforge\envs\z\lib\site-packages\osgeo\gdal.py", line 5283, in ReadAsArray
from osgeo import gdal_array
File "D:\codetool\mambaforge\envs\z\lib\site-packages\osgeo\gdal_array.py", line 10, in <module>
from . import _gdal_array
ImportError: DLL load failed while importing _gdal_array: The specified module could not be found.```
code_textI don't understand why this happens. Could anyone help me troubleshoot this issue?
-
Hi and welcome to devnet,
Does you script work properly when called directly on the command line in your conda environment ?
Are you starting your application within the activated conda environment ? -
Does you script work properly when called directly on the command line in your conda environment ?
Are you starting your application within the activated conda environment ?Dear SGaist:
Yes, my code can run properly in the conda environment. When I call the Python program from Qt, the code from osgeo import gdal works normally and all methods from the gdal module function correctly. However, when I try from osgeo import gdal_array, it produces the error I mentioned earlier. In Qt, I've set the Python interpreter location to point to the activated virtual environment in conda.
Zhou -
-
Glad you found out and thanks for sharing !
How did you end up with two different versions of that library ?