<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Conda cloned environment has problems with GDAL in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/conda-cloned-environment-has-problems-with-gdal/m-p/1352444#M75459</link>
    <description>&lt;P&gt;Currently, the problem is solved. The 'gdal'-update that happened, is not performed any more.&lt;BR /&gt;Since 'gdal' is stable, the environment is stable.&lt;BR /&gt;&lt;BR /&gt;But this could change again, over time.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Nov 2023 10:13:19 GMT</pubDate>
    <dc:creator>Dumbatz</dc:creator>
    <dc:date>2023-11-22T10:13:19Z</dc:date>
    <item>
      <title>Conda cloned environment has problems with GDAL</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/conda-cloned-environment-has-problems-with-gdal/m-p/1344909#M74756</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I have a problem with a clone of the standard 'arcgispro-py3' environment.&lt;/P&gt;&lt;P&gt;I am working with ArcGIS Pro 3.0.5. As I am employed the device is owned and managed by the company, which leaves no way of changing the ArcGIS installation.&lt;/P&gt;&lt;P&gt;However, to gain some freedome in the use of 'arcpy', I do create clones of the standard environment. Therefore, I go to the directory that contains the 'conda'-related scripts and clone the environment in the C:\Program\ArcGIS\Pro\bin\Python\envs&lt;BR /&gt;to&lt;BR /&gt;C:\Users\*\AppData\*\envs.&lt;BR /&gt;I do create a clone in order to install the 'esda' package which conveniently comes with 'libpysal', that I also need. Now, to prevent any major hiccups&amp;nbsp;and knowing the issue that comes up, I do pin the ‘gdal’ to 3.4.0.&lt;BR /&gt;I perform all installations of packages in cloned environments through the command line and the ‘conda’-related scripts.&lt;/P&gt;&lt;P&gt;I have a .pyt based Toolbox, that uses subscripts. These should employ ‘gdal’, ‘esda’, and ‘libpysal’.&lt;/P&gt;&lt;P&gt;What I tested:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Clone environment, NOT installing ‘esda’ and ‘libpysal’, disabling the sections in the script that need these, and disabling the ‘import’ of said packages.&lt;BR /&gt;‘from osgeo import gdal’ is used.&lt;BR /&gt;Then, said toolbox and script can be run over and over, within one session of ArcGIS Pro, or closing Pro and opening Pro again.&lt;BR /&gt;The cloned environment and all package dependencies are stable.&lt;/LI&gt;&lt;LI&gt;Installing ‘esda’ and ‘libpysal’ (while ArcGIS Pro can be opened or closed).&lt;BR /&gt;Note:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;gdal                           3.4.0-arcgispro_py39_17119 --&amp;gt; 3.4.0-arcgispro_py39_17150​&lt;/LI-CODE&gt;&lt;P&gt;This happens along with the otherwise flawless installation.&lt;BR /&gt;&lt;BR /&gt;I enable the sections of the script that use ‘esda’ and ‘libpysal’ functionality, ‘import’ the packages.&lt;BR /&gt;Also,&amp;nbsp;‘from osgeo import gdal’ is used.&lt;BR /&gt;Then I (start ArcGIS Pro and) open the toolbox, the syntax check is successful, NO errors.&lt;BR /&gt;The toolbox can be used again and again.&lt;BR /&gt;&lt;BR /&gt;But, if I now close ArcGIS Pro (the day might be over), and then come back to it and want to use the Toolbox, I get an error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;Traceback (most recent call last):
  File "C:\Users\schwenk_m\AppData\Local\ESRI\conda\envs\MSdev39ArcPy\Lib\site-packages\osgeo\__init__.py", line 40, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\schwenk_m\AppData\Local\ESRI\conda\envs\MSdev39ArcPy\Lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1030, in _gcd_import
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1007, in _find_and_load
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 986, in _find_and_load_unlocked
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 666, in _load_unlocked
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 565, in module_from_spec
  File "&amp;lt;frozen importlib._bootstrap_external&amp;gt;", line 1173, in create_module
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 228, in _call_with_frames_removed
ImportError: DLL load failed while importing _gdal: Die angegebene Prozedur wurde nicht gefunden.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "&amp;lt;string&amp;gt;", line 17, in &amp;lt;module&amp;gt;
  File "C:\Users\schwenk_m\Documents\ArcGIS\Projects\Geo_gen\RasterSurfaceAnalysis.py", line 23, in &amp;lt;module&amp;gt;
    from osgeo import gdal
  File "C:\Users\schwenk_m\AppData\Local\ESRI\conda\envs\MSdev39ArcPy\Lib\site-packages\osgeo\__init__.py", line 56, in &amp;lt;module&amp;gt;
    _gdal = swig_import_helper()
  File "C:\Users\schwenk_m\AppData\Local\ESRI\conda\envs\MSdev39ArcPy\Lib\site-packages\osgeo\__init__.py", line 52, in swig_import_helper
    raise ImportError(traceback_string + '\n' + msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\schwenk_m\AppData\Local\ESRI\conda\envs\MSdev39ArcPy\Lib\site-packages\osgeo\__init__.py", line 40, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\schwenk_m\AppData\Local\ESRI\conda\envs\MSdev39ArcPy\Lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1030, in _gcd_import
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1007, in _find_and_load
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 986, in _find_and_load_unlocked
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 666, in _load_unlocked
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 565, in module_from_spec
  File "&amp;lt;frozen importlib._bootstrap_external&amp;gt;", line 1173, in create_module
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 228, in _call_with_frames_removed
ImportError: DLL load failed while importing _gdal: Die angegebene Prozedur wurde nicht gefunden.

On Windows, with Python &amp;gt;= 3.8, DLLs are no longer imported from the PATH.
If gdalXXX.dll is in the PATH, then set the USE_PATH_FOR_GDAL_PYTHON=YES environment variable
to feed the PATH into os.add_dll_directory().&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My questions is, what happend to the environment through the installation of the new packages, and by closing and opening ArcGIS Pro?&lt;BR /&gt;&lt;BR /&gt;For all that I tryed, I could not, as suggested, set the option '&lt;STRONG&gt;USE_PATH_FOR_GDAL_PYTHON=YES'.&lt;BR /&gt;&lt;/STRONG&gt;I did not grasp how to exactly use the command&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;conda env config vars list
USE_PATH_FOR_GDAL_PYTHON=YES&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;that was suggested&amp;nbsp;&lt;A title="gdal, conda-forge" href="https://github.com/conda-forge/gdal-feedstock/issues/541" target="_self"&gt;here.&lt;/A&gt;&amp;nbsp;However, I did add the line to the '.condarc' file in my Home directory, which does not help.&lt;/P&gt;&lt;P&gt;Furthermore, upon inspection all the .py scripts related to GDAL in the OSGEO folder are still there.&lt;/P&gt;&lt;P&gt;I am thankful for any pointers.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 12:42:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/conda-cloned-environment-has-problems-with-gdal/m-p/1344909#M74756</guid>
      <dc:creator>Dumbatz</dc:creator>
      <dc:date>2023-11-02T12:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Conda cloned environment has problems with GDAL</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/conda-cloned-environment-has-problems-with-gdal/m-p/1345073#M74773</link>
      <description>&lt;P&gt;True. Thanks for the suggestion.&lt;BR /&gt;This is what I do, although I do not work with VS Code.&lt;BR /&gt;&lt;BR /&gt;The problem is, that the enviornment is 'distroyed' by the ArcGIS Pro program itself. After using the toolbox in one instance, I cannot use it again.&lt;BR /&gt;If I activate the environment on a command prompt, and call Python, the "from osgeo import gdal" is no longer functional.&lt;/P&gt;&lt;P&gt;The cloned environment is kaputt.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 16:25:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/conda-cloned-environment-has-problems-with-gdal/m-p/1345073#M74773</guid>
      <dc:creator>Dumbatz</dc:creator>
      <dc:date>2023-11-02T16:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Conda cloned environment has problems with GDAL</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/conda-cloned-environment-has-problems-with-gdal/m-p/1352444#M75459</link>
      <description>&lt;P&gt;Currently, the problem is solved. The 'gdal'-update that happened, is not performed any more.&lt;BR /&gt;Since 'gdal' is stable, the environment is stable.&lt;BR /&gt;&lt;BR /&gt;But this could change again, over time.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2023 10:13:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/conda-cloned-environment-has-problems-with-gdal/m-p/1352444#M75459</guid>
      <dc:creator>Dumbatz</dc:creator>
      <dc:date>2023-11-22T10:13:19Z</dc:date>
    </item>
  </channel>
</rss>

