<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">Le 13/10/2021 à 14:05, Pedro Venâncio a
      écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:CAMCJChusEtG_0uc_wdZWCBLrnxuoE1dMpQxaMa=_-AJn1ufQBQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>Hi Even,</div>
        <div><br>
        </div>
        <div>Thanks for your help!</div>
        <div><br>
        </div>
        <div>Yes, I've tried "set USE_PATH_FOR_GDAL_PYTHON=YES" but the
          behaviour does not change.</div>
        <div><br>
        </div>
        <div>
          I believe OSGeo4W shell sets the environment variables through
          .bat files, and does not use system path. Am I right, Jurgen?
          (sorry for calling in CC)</div>
      </div>
    </blockquote>
    I'd be curious to know if you could confirm if the OSGeo4W shell
    does set it or not<br>
    <blockquote type="cite"
cite="mid:CAMCJChusEtG_0uc_wdZWCBLrnxuoE1dMpQxaMa=_-AJn1ufQBQ@mail.gmail.com">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Meanwhile I've found those issue and PR that seems related:</div>
        <div><a href="https://github.com/OSGeo/gdal/issues/3898"
            moz-do-not-send="true">https://github.com/OSGeo/gdal/issues/3898</a></div>
        <div><a href="https://github.com/OSGeo/gdal/pull/3923"
            moz-do-not-send="true">https://github.com/OSGeo/gdal/pull/3923</a></div>
      </div>
    </blockquote>
    <p>I don't think they are. And that fix is in 3.3.2</p>
    <p>But I don't understand why you still get the "On Windows, with
      Python >= 3.8, DLLs are no longer imported from the PATH."
      error message. <br>
    </p>
    <p>It shouldn't be emitted because USE_PATH_FOR_GDAL_PYTHON is set:
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/blob/f3a83a2c2628219bdc60001580da677758015a60/gdal/swig/python/osgeo/__init__.py#L25">https://github.com/OSGeo/gdal/blob/f3a83a2c2628219bdc60001580da677758015a60/gdal/swig/python/osgeo/__init__.py#L25</a></p>
    <p>Something weird happening here. Perhaps edit
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/blob/f3a83a2c2628219bdc60001580da677758015a60/gdal/swig/python/osgeo/__init__.py#L25">https://github.com/OSGeo/gdal/blob/f3a83a2c2628219bdc60001580da677758015a60/gdal/swig/python/osgeo/__init__.py#L25</a>
      to display os.environ<br>
    </p>
    <blockquote type="cite"
cite="mid:CAMCJChusEtG_0uc_wdZWCBLrnxuoE1dMpQxaMa=_-AJn1ufQBQ@mail.gmail.com">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Following the steps to reproduce the problem I get the
          error message:</div>
        <div>
          <p>C:\Users\PedroVenancio\demo.py:</p>
          <div class="gmail-snippet-clipboard-content
            gmail-position-relative">
            <pre><code>from osgeo import gdal
</code></pre>
          </div>
        </div>
        <div>
          <pre class="gmail-code gmail-highlight" lang="plaintext"><span id="gmail-LC1" class="gmail-line" lang="plaintext">
<span id="gmail-LC1" class="gmail-line" lang="plaintext">(arosics) PS C:\Users\PedroVenancio> gdalinfo --version</span>
<span id="gmail-LC2" class="gmail-line" lang="plaintext">GDAL 3.3.2, released 2021/09/01</span>

(arosics) PS C:\Users\PedroVenancio> set USE_PATH_FOR_GDAL_PYTHON=YES</span>

<span id="gmail-LC2" class="gmail-line" lang="plaintext">(arosics) PS C:\Users\PedroVenancio> python demo.py</span>

<span id="gmail-LC3" class="gmail-line" lang="plaintext">Traceback (most recent call last):</span>
<span id="gmail-LC4" class="gmail-line" lang="plaintext">  File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\site-packages\osgeo\__init__.py", line 21, in swig_import_helper</span>
<span id="gmail-LC5" class="gmail-line" lang="plaintext">    return importlib.import_module(mname)</span>
<span id="gmail-LC6" class="gmail-line" lang="plaintext">  File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\importlib\__init__.py", line 127, in import_module</span>
<span id="gmail-LC7" class="gmail-line" lang="plaintext">    return _bootstrap._gcd_import(name[level:], package, level)</span>
<span id="gmail-LC8" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import</span>
<span id="gmail-LC9" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap>", line 991, in _find_and_load</span>
<span id="gmail-LC10" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked</span>
<span id="gmail-LC11" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap>", line 657, in _load_unlocked</span>
<span id="gmail-LC12" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap>", line 556, in module_from_spec</span>
<span id="gmail-LC13" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap_external>", line 1166, in create_module</span>
<span id="gmail-LC14" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed</span>
<span id="gmail-LC15" class="gmail-line" lang="plaintext">ImportError: DLL load failed while importing _gdal: Impossível localizar o procedimento especificado.</span>
<span id="gmail-LC16" class="gmail-line" lang="plaintext"></span>
<span id="gmail-LC17" class="gmail-line" lang="plaintext">During handling of the above exception, another exception occurred:</span>
<span id="gmail-LC18" class="gmail-line" lang="plaintext"></span>
<span id="gmail-LC19" class="gmail-line" lang="plaintext">Traceback (most recent call last):</span>
<span id="gmail-LC20" class="gmail-line" lang="plaintext">  File "demo.py", line 1, in <module></span>
<span id="gmail-LC21" class="gmail-line" lang="plaintext">    from osgeo import gdal</span>
<span id="gmail-LC22" class="gmail-line" lang="plaintext">  File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\site-packages\osgeo\__init__.py", line 37, in <module></span>
<span id="gmail-LC23" class="gmail-line" lang="plaintext">    _gdal = swig_import_helper()</span>
<span id="gmail-LC24" class="gmail-line" lang="plaintext">  File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\site-packages\osgeo\__init__.py", line 33, in swig_import_helper</span>
<span id="gmail-LC25" class="gmail-line" lang="plaintext">    raise ImportError(traceback_string + '\n' + msg)</span>
<span id="gmail-LC26" class="gmail-line" lang="plaintext">ImportError: Traceback (most recent call last):</span>
<span id="gmail-LC27" class="gmail-line" lang="plaintext">  File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\site-packages\osgeo\__init__.py", line 21, in swig_import_helper</span>
<span id="gmail-LC28" class="gmail-line" lang="plaintext">    return importlib.import_module(mname)</span>
<span id="gmail-LC29" class="gmail-line" lang="plaintext">  File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\importlib\__init__.py", line 127, in import_module</span>
<span id="gmail-LC30" class="gmail-line" lang="plaintext">    return _bootstrap._gcd_import(name[level:], package, level)</span>
<span id="gmail-LC31" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import</span>
<span id="gmail-LC32" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap>", line 991, in _find_and_load</span>
<span id="gmail-LC33" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked</span>
<span id="gmail-LC34" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap>", line 657, in _load_unlocked</span>
<span id="gmail-LC35" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap>", line 556, in module_from_spec</span>
<span id="gmail-LC36" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap_external>", line 1166, in create_module</span>
<span id="gmail-LC37" class="gmail-line" lang="plaintext">  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed</span>
<span id="gmail-LC38" class="gmail-line" lang="plaintext">ImportError: DLL load failed while importing _gdal: Impossível localizar o procedimento especificado.</span>
<span id="gmail-LC39" class="gmail-line" lang="plaintext"></span>
<span id="gmail-LC40" class="gmail-line" lang="plaintext">On Windows, with Python >= 3.8, DLLs are no longer imported from the PATH.</span>
<span id="gmail-LC41" class="gmail-line" lang="plaintext">If gdalXXX.dll is in the PATH, then set the USE_PATH_FOR_GDAL_PYTHON=YES environment variable</span>
<span id="gmail-LC42" class="gmail-line" lang="plaintext">to feed the PATH into os.add_dll_directory().</span>
</pre>
        </div>
        <div><br>
        </div>
        <div>Are those ones really related?</div>
        <div><br>
        </div>
        <div>Thanks Even and Jurgen!</div>
        <div><br>
        </div>
        <div>Pedro</div>
        <div><br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">Even Rouault <<a
            href="mailto:even.rouault@spatialys.com"
            moz-do-not-send="true">even.rouault@spatialys.com</a>>
          escreveu no dia quarta, 13/10/2021 à(s) 11:43:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div>
            <p>Pedro,</p>
            <p>Did you try to "set USE_PATH_FOR_GDAL_PYTHON=YES"
              environment variable a suggested ?</p>
            <p>Can you check if it set in OSGeo4W shell ?  ("echo
              %USE_PATH_FOR_GDAL_PYTHON%")</p>
            <p>Wondering if we shouldn't enable that behavior
              automatically... although that we would go against
              upstream Python policy</p>
            <p>Even<br>
            </p>
            <div>Le 13/10/2021 à 12:14, Pedro Venâncio a écrit :<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">
                <div>Hi all,</div>
                <div><br>
                </div>
                <div>I'm trying to create an Anaconda environment to run
                  arosics, a software that performs automatic subpixel
                  co-registration of two satellite image datasets. <br>
                </div>
                <div><br>
                </div>
                <div>The environment seems correctly created, with GDAL
                  working as expected on the CLI:</div>
                <div>
                  <pre lang="plaintext"><span id="gmail-m_8153721162495511059gmail-LC1" lang="plaintext">(arosics) PS C:\Users\PedroVenancio> gdalinfo --version</span>
<span id="gmail-m_8153721162495511059gmail-LC2" lang="plaintext">GDAL 3.3.2, released 2021/09/01</span>
</pre>
                </div>
                <div><br>
                </div>
                <div>The problem is that when Python (versions >=3.8)
                  calls GDAL, it gives an error:</div>
                <div>
                  <pre lang="plaintext"><span id="gmail-m_8153721162495511059gmail-LC4" lang="plaintext">(arosics) PS C:\Users\PedroVenancio> python</span>
<span id="gmail-m_8153721162495511059gmail-LC5" lang="plaintext">Python 3.8.12 | packaged by conda-forge | (default, Oct 12 2021, 21:22:46) [MSC v.1916 64 bit (AMD64)] on win32</span>
<span id="gmail-m_8153721162495511059gmail-LC6" lang="plaintext">Type "help", "copyright", "credits" or "license" for more information.</span>
<span id="gmail-m_8153721162495511059gmail-LC7" lang="plaintext"></span>
<span id="gmail-m_8153721162495511059gmail-LC8" lang="plaintext">>>> from osgeo import gdal</span>
<span id="gmail-m_8153721162495511059gmail-LC9" lang="plaintext">Traceback (most recent call last):</span>
<span id="gmail-m_8153721162495511059gmail-LC10" lang="plaintext">  File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\site-packages\osgeo\__init__.py", line 21, in swig_import_helper</span>
<span id="gmail-m_8153721162495511059gmail-LC11" lang="plaintext">    return importlib.import_module(mname)</span>
<span id="gmail-m_8153721162495511059gmail-LC12" lang="plaintext">  File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\importlib\__init__.py", line 127, in import_module</span>
<span id="gmail-m_8153721162495511059gmail-LC13" lang="plaintext">    return _bootstrap._gcd_import(name[level:], package, level)</span>
<span id="gmail-m_8153721162495511059gmail-LC14" lang="plaintext">  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import</span>
<span id="gmail-m_8153721162495511059gmail-LC15" lang="plaintext">  File "<frozen importlib._bootstrap>", line 991, in _find_and_load</span>
<span id="gmail-m_8153721162495511059gmail-LC16" lang="plaintext">  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked</span>
<span id="gmail-m_8153721162495511059gmail-LC17" lang="plaintext">  File "<frozen importlib._bootstrap>", line 657, in _load_unlocked</span>
<span id="gmail-m_8153721162495511059gmail-LC18" lang="plaintext">  File "<frozen importlib._bootstrap>", line 556, in module_from_spec</span>
<span id="gmail-m_8153721162495511059gmail-LC19" lang="plaintext">  File "<frozen importlib._bootstrap_external>", line 1166, in create_module</span>
<span id="gmail-m_8153721162495511059gmail-LC20" lang="plaintext">  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed</span>
<span id="gmail-m_8153721162495511059gmail-LC21" lang="plaintext">ImportError: DLL load failed while importing _gdal: Impossível localizar o procedimento especificado.</span>
<span id="gmail-m_8153721162495511059gmail-LC22" lang="plaintext"></span>
<span id="gmail-m_8153721162495511059gmail-LC23" lang="plaintext">During handling of the above exception, another exception occurred:</span>
<span id="gmail-m_8153721162495511059gmail-LC24" lang="plaintext"></span>
<span id="gmail-m_8153721162495511059gmail-LC25" lang="plaintext">Traceback (most recent call last):</span>
<span id="gmail-m_8153721162495511059gmail-LC26" lang="plaintext">  File "<stdin>", line 1, in <module></span>
<span id="gmail-m_8153721162495511059gmail-LC27" lang="plaintext">  File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\site-packages\osgeo\__init__.py", line 37, in <module></span>
<span id="gmail-m_8153721162495511059gmail-LC28" lang="plaintext">    _gdal = swig_import_helper()</span>
<span id="gmail-m_8153721162495511059gmail-LC29" lang="plaintext">  File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\site-packages\osgeo\__init__.py", line 33, in swig_import_helper</span>
<span id="gmail-m_8153721162495511059gmail-LC30" lang="plaintext">    raise ImportError(traceback_string + '\n' + msg)</span>
<span id="gmail-m_8153721162495511059gmail-LC31" lang="plaintext">ImportError: Traceback (most recent call last):</span>
<span id="gmail-m_8153721162495511059gmail-LC32" lang="plaintext">  File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\site-packages\osgeo\__init__.py", line 21, in swig_import_helper</span>
<span id="gmail-m_8153721162495511059gmail-LC33" lang="plaintext">    return importlib.import_module(mname)</span>
<span id="gmail-m_8153721162495511059gmail-LC34" lang="plaintext">  File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\importlib\__init__.py", line 127, in import_module</span>
<span id="gmail-m_8153721162495511059gmail-LC35" lang="plaintext">    return _bootstrap._gcd_import(name[level:], package, level)</span>
<span id="gmail-m_8153721162495511059gmail-LC36" lang="plaintext">  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import</span>
<span id="gmail-m_8153721162495511059gmail-LC37" lang="plaintext">  File "<frozen importlib._bootstrap>", line 991, in _find_and_load</span>
<span id="gmail-m_8153721162495511059gmail-LC38" lang="plaintext">  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked</span>
<span id="gmail-m_8153721162495511059gmail-LC39" lang="plaintext">  File "<frozen importlib._bootstrap>", line 657, in _load_unlocked</span>
<span id="gmail-m_8153721162495511059gmail-LC40" lang="plaintext">  File "<frozen importlib._bootstrap>", line 556, in module_from_spec</span>
<span id="gmail-m_8153721162495511059gmail-LC41" lang="plaintext">  File "<frozen importlib._bootstrap_external>", line 1166, in create_module</span>
<span id="gmail-m_8153721162495511059gmail-LC42" lang="plaintext">  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed</span>
<span id="gmail-m_8153721162495511059gmail-LC43" lang="plaintext">ImportError: DLL load failed while importing _gdal: Impossível localizar o procedimento especificado.</span>
<span id="gmail-m_8153721162495511059gmail-LC44" lang="plaintext"></span>
<span id="gmail-m_8153721162495511059gmail-LC45" lang="plaintext">On Windows, with Python >= 3.8, DLLs are no longer imported from the PATH.</span>
<span id="gmail-m_8153721162495511059gmail-LC46" lang="plaintext">If gdalXXX.dll is in the PATH, then set the USE_PATH_FOR_GDAL_PYTHON=YES environment variable</span>
<span id="gmail-m_8153721162495511059gmail-LC47" lang="plaintext">to feed the PATH into os.add_dll_directory().</span>
</pre>
                </div>
                <div>I've reported this error in the arosics issue
                  tracker (<a
                    href="https://git.gfz-potsdam.de/danschef/arosics/-/issues/66"
                    target="_blank" moz-do-not-send="true">https://git.gfz-potsdam.de/danschef/arosics/-/issues/66</a>),
                  but it seems to be working as expected in some similar
                  systems (windows 10). <br>
                </div>
                <div><br>
                </div>
                <div>So I believe it can be some kind of conflict with
                  other installations on my machine. I've for instance
                  OSGeo4W and everything works fine:</div>
                <div>
                  <pre lang="plaintext"><span id="gmail-m_8153721162495511059gmail-LC2" lang="plaintext">C:\OSGeo4W>gdalinfo --version</span>
<span id="gmail-m_8153721162495511059gmail-LC3" lang="plaintext">GDAL 3.3.1, released 2021/06/28</span>
<span id="gmail-m_8153721162495511059gmail-LC4" lang="plaintext"></span>
<span id="gmail-m_8153721162495511059gmail-LC5" lang="plaintext">C:\OSGeo4W>python</span>
<span id="gmail-m_8153721162495511059gmail-LC6" lang="plaintext">Python 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32</span>
<span id="gmail-m_8153721162495511059gmail-LC7" lang="plaintext">Type "help", "copyright", "credits" or "license" for more information.</span>
<span id="gmail-m_8153721162495511059gmail-LC8" lang="plaintext"></span>
<span id="gmail-m_8153721162495511059gmail-LC9" lang="plaintext">>>> from osgeo import gdal</span>
<span id="gmail-m_8153721162495511059gmail-LC10" lang="plaintext">>>> gdal</span>
<span id="gmail-m_8153721162495511059gmail-LC11" lang="plaintext"><module 'osgeo.gdal' from 'C:\\OSGeo4W\\apps\\Python39\\lib\\site-packages\\osgeo\\gdal.py'></span>
</pre>
                </div>
                <div><br>
                </div>
                <div>Has anyone seen this kind of error? Any hints to
                  overcome?</div>
                <div><br>
                </div>
                <div>Thank you very much!</div>
                <div><br>
                </div>
                <div>Best regards,</div>
                <div>Pedro</div>
                <div><br>
                </div>
              </div>
              <br>
              <fieldset></fieldset>
              <pre>_______________________________________________
gdal-dev mailing list
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank" moz-do-not-send="true">gdal-dev@lists.osgeo.org</a>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
            </blockquote>
            <pre cols="72">-- 
<a href="http://www.spatialys.com" target="_blank" moz-do-not-send="true">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
          </div>
        </blockquote>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </body>
</html>