Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. gdal
Qt 6.11 is out! See what's new in the release blog

gdal

Scheduled Pinned Locked Moved Solved Language Bindings
5 Posts 2 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zhooukee
    wrote on last edited by
    #1

    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_text

    
    I don't understand why this happens.
    
    Could anyone help me troubleshoot this issue?
    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      zhooukee
      wrote on last edited by zhooukee
      #4

      Now I have solved this problem. The GDAL versions for C++ and Python must match.!

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        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 ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Z 1 Reply Last reply
        0
        • SGaistS SGaist

          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 ?

          Z Offline
          Z Offline
          zhooukee
          wrote on last edited by
          #3

          @SGaist said in gdal:

          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

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            zhooukee
            wrote on last edited by zhooukee
            #4

            Now I have solved this problem. The GDAL versions for C++ and Python must match.!

            1 Reply Last reply
            1
            • Z zhooukee has marked this topic as solved on
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #5

              Glad you found out and thanks for sharing !

              How did you end up with two different versions of that library ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved