Suggested GDAL version (>=3.4.2, <3.6.0) for InVEST cannot be found

When installing NatCap with conda install -c conda-forge natcap.invest, the suggested GDAL version (>=3.4.2, <3.6.0) for InVEST cannot be found, as it is no longer available. The latest version available is GDAL 3.7. Attempting the installation results in the following error:LibMambaUnsatisfiableError: Encountered problems while solving:

  • package natcap.invest-3.14.1-py311h12feb9d_0 requires gdal >=3.4.2,<3.6.0, but none of the providers can be installd. Any suggestions on how to resolve this issue would be greatly appreciated.

Hi @MartijnS , it appears you are trying to install 3.14.1, which does have those GDAL version restrictions.

The latest available natcap.invest on conda-forge is 3.14.3, which should only require β€œGDAL>=3.4.2”.
https://anaconda.org/conda-forge/natcap.invest

And the latest available GDAL appears to be 3.10.1
https://anaconda.org/conda-forge/gdal

I would expect conda install -c conda-forge natcap.invest to install 3.14.3.

Sometimes the most efficient way to resolve these issues is to create a fresh new conda environment and start from there. If you’re starting fresh, I would recommend Python 3.12, though anything above 3.9 should work.

1 Like

Dear Dave,

Thanks for the prompt response. I am asssistng MartijnS on this, and have tried various variant. To no avail unfortunately.

We have installed the β€˜invest workbench 3.14.3’ as desktop application, which seems to be the latest you can download from the support page.

As for the conda package, I have tried the following.
(Where β€˜arcgispro-py3-invest311’ the conda env is we are trying install into)

conda install -n arcgispro-py3-invest311 -c conda-forge natcap.invest

LibMambaUnsatisfiableError: Encountered problems while solving:

  • package natcap.invest-3.14.1-py311h12feb9d_0 requires gdal >=3.4.2,<3.6.0, but none of the providers can be installd

conda install -n arcgispro-py3-invest conda-forge::natcap.invest=3.14.3
resulting into :
LibMambaUnsatisfiableError: Encountered problems while solving:

  • package natcap.invest-3.14.3-py311h9b10771_0 requires gdal >=3.4.2,<3.6.0, but none of the providers can be installd

Hi Dave, Do you have any updates yet? We’re a bit short on time.

Best, Martijn

Thanks for trying this. I’m surprised to see that natcap.invest 3.14.3 has the gdal<3.6.0 restriction. I think that is probably an error on our part, in the conda-forge recipe.

As a workaround, you could perhaps install all the dependencies into an environment using conda. But then as a final step, install natcap.invest using pip instead of conda: pip install natcap.invest --no-deps.

You can reference the list of dependencies here: invest/requirements.txt at main Β· natcap/invest Β· GitHub

Hi Dave,

Thanks for getting back to me. We’re a bit short on time, so we really appreciate your quick responses. We’ll give it a try and let you know how it goes.

Best,

Martijn

We think we have fixed our conda-forge recipe as well. So if you wish, you may once again try conda install -c conda-forge natcap.invest and version 3.14.3 should no longer have that strict gdal requirement.

Hey Dave,

When importing invest, we’re getting the following warning:

FutureWarning:
natcap.invest requires GDAL exceptions to be enabled. You must
call gdal.UseExceptions() to avoid unexpected behavior from
natcap.invest. A future version will enable exceptions on import.
gdal.UseExceptions affects global state, so this may affect the
behavior of other packages.

It doesn’t seem to be a direct issue and should be resolved in a future GDAL version. Let me know if you think we should take any action in the meantime.

Best,
Martijn

Glad to hear you got it installed.

natcap.invest requires GDAL exceptions to be enabled.

If you wish to take action, this is what we recommend:

call gdal.UseExceptions() to avoid unexpected behavior from
natcap.invest.

For example, if you have a script where you are running an invest model,

from osgeo import gdal
gdal.UseExceptions()

from natcap.invest import carbon
...
carbon.execute(args)

Some more details here:
https://gdal.org/en/stable/api/python_gotchas.html#python-bindings-do-not-raise-exceptions-unless-you-explicitly-call-useexceptions

Hi Dave,

We’re trying to install NatCap.InVEST in the Python environment of ArcGIS Pro (version 3.11.10), but we’re running into some issues.
Below are the steps we’ve taken so far:

First Attempt: Cloning ArcGIS Pro Environment
We tried cloning the existing arcgispro-py3 environment and then installing NatCap.InVEST:

$invest_env_name = β€œinvest311”

conda activate arcgispro-py3
conda create --clone arcgispro-py3 --name $invest_env_name -y
conda install -c conda-forge --name $invest_env_name natcap.invest
β†’ This failed: NatCap.InVEST could not be installed in the cloned environment.

Second Attempt: Creating a Fresh Environment
Since cloning didn’t work, we created a new environment from scratch with Python 3.11 and installed NatCap.InVEST:

conda create -n $invest_env_name python=3.11 -y
conda install -c conda-forge -n $invest_env_name natcap.invest -y
β†’ This worked, but arcpy is missing.

The Problem:
A cloned ArcGIS Pro environment does not allow NatCap.InVEST to be installed.
A fresh environment allows NatCap.InVEST, but does not include arcpy.

Do you have any ideas on how we can get both NatCap.InVEST and arcpy working in the same environment?

Thanks in advance!

Below are the steps taken during the installation and the error message that occurs. Maybe you can see what is going wrong.

version 3.14.1 is listed when no version is given, while 3.14.3 is latest
all give this error below
gdal pin requirements seems still active
python.exe in env is 3.11.10x while β€˜pin-1’ requires 3.11…?!

PS C:\Users\a_mammerlaan> conda install -c conda-forge -n arcgispro-py3-invest311 natcap.invest
Channels:

  • conda-forge
  • esri
  • defaults
    Platform: win-64
    Collecting package metadata (repodata.json): done
    Solving environment: / warning libmamba Added empty dependency for problem type SOLVER_RULE_UPDATE
    failed

LibMambaUnsatisfiableError: Encountered problems while solving:

  • package natcap.invest-3.14.1-py311h12feb9d_0 requires gdal >=3.4.2,<3.6.0, but none of the providers can be installd
    Could not solve for environment specs
    The following packages are incompatible
    β”œβ”€ natcap.invest is installable with the potential options
    β”‚ β”œβ”€ natcap.invest [3.14.1|3.14.2|3.14.3] would require
    β”‚ β”‚ └─ gdal >=3.4.2,<3.6.0 with the potential options
    β”‚ β”‚ β”œβ”€ gdal [3.3.3|3.4.0|…|3.6.4] would require
    β”‚ β”‚ β”‚ └─ python >=3.10,<3.11.0a0 , which can be installed;
    β”‚ β”‚ β”œβ”€ gdal [3.0.4|3.1.0|…|3.6.0] would require
    β”‚ β”‚ β”‚ └─ python [3.7.* |>=3.7,<3.8.0a0 ], which can be installed;
    β”‚ β”‚ β”œβ”€ gdal [3.0.4|3.1.0|…|3.6.4] would require
    β”‚ β”‚ β”‚ └─ python >=3.8,<3.9.0a0 , which can be installed;
    β”‚ β”‚ β”œβ”€ gdal [3.1.3|3.1.4|…|3.6.4] would require
    β”‚ β”‚ β”‚ └─ python [3.9.* |>=3.9,<3.10.0a0 ], which can be installed;
    β”‚ β”‚ └─ gdal [3.5.2|3.5.3|…|3.6.4] would require
    β”‚ β”‚ └─ libgdal [3.5.2 h263b2b1_7|3.5.2 h283e77c_7|…|3.6.4 hf26a062_3], which requires
    β”‚ β”‚ └─ libzlib >=1.2.13,<2.0.0a0 with the potential options
    β”‚ β”‚ β”œβ”€ libzlib 1.2.13 would require
    β”‚ β”‚ β”‚ └─ zlib 1.2.13 _4, which can be installed;
    β”‚ β”‚ β”œβ”€ libzlib 1.2.13 would require
    β”‚ β”‚ β”‚ └─ zlib 1.2.13 _6, which can be installed;
    β”‚ β”‚ β”œβ”€ libzlib 1.2.13 would require
    β”‚ β”‚ β”‚ └─ zlib 1.2.13 _5, which can be installed;
    β”‚ β”‚ β”œβ”€ libzlib 1.3 would require
    β”‚ β”‚ β”‚ └─ zlib 1.3 _0, which can be installed;
    β”‚ β”‚ β”œβ”€ libzlib 1.3.1 would require
    β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime >=14.29.30139 with the potential options
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.29.30139 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.29.30139.
    _24, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.29.30139 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.29.30139.
    , which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.29.30139 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.29.30139.
    _14, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.29.30139 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.29.30139.
    _15, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.29.30139 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.29.30139.
    _16, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.29.30139 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.29.30139.
    _17, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.29.30139 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.29.30139.
    _18, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.29.30139 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.29.30139.
    _20, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.29.30139 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.29.30139.
    _21, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.29.30139 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.29.30139.
    _22, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.29.30139 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.29.30139.
    _23, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.32.31332 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.32.31332.
    , which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.32.31332 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.32.31332.
    _14, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.32.31332 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.32.31332.
    _15, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.32.31332 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.32.31332.
    _16, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.32.31332 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.32.31332.
    _17, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.34.31931 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.34.31931.
    , which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.34.31931 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.34.31931.
    _14, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.34.31931 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.34.31931.
    _15, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.34.31931 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.34.31931.
    _16, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.34.31931 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.34.31931.
    _17, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.36.32532 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.36.32532.
    _17, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.36.32532 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.36.32532.
    _16, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.38.33130 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.38.33130.
    _20, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.38.33130 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.38.33130.
    _18, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.38.33135 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.38.33135.
    _20, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.38.33135 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.38.33135.
    _21, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.38.33135 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.38.33135.
    _22, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.38.33135 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.38.33135.
    _23, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.38.33135 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.38.33135.
    _24, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.40.33810 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.40.33810.
    _24, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.40.33810 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.40.33810.
    _20, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.40.33810 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.40.33810.
    _21, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.40.33810 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.40.33810.
    _22, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.40.33810 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.40.33810.
    _23, which can be installed;
    β”‚ β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime 14.42.34433 would require
    β”‚ β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.42.34433.
    _24, which can be installed;
    β”‚ β”‚ β”‚ β”‚ └─ vc14_runtime 14.42.34433 would require
    β”‚ β”‚ β”‚ β”‚ └─ vs2015_runtime 14.42.34433.
    *_23, which can be installed;
    β”‚ β”‚ β”‚ └─ zlib 1.3.1 _1, which can be installed;
    β”‚ β”‚ β”œβ”€ libzlib 1.3.1 would require
    β”‚ β”‚ β”‚ β”œβ”€ vc14_runtime >=14.29.30139 , which can be installed (as previously explained);
    β”‚ β”‚ β”‚ └─ zlib 1.3.1 _2, which can be installed;
    β”‚ β”‚ └─ libzlib 1.3.1 would require
    β”‚ β”‚ β”œβ”€ vc14_runtime >=14.29.30139 , which can be installed (as previously explained);
    β”‚ β”‚ └─ zlib 1.3.1 _0, which can be installed;
    β”‚ β”œβ”€ natcap.invest [3.10.1|3.10.2] would require
    β”‚ β”‚ └─ python >=3.7,<3.8.0a0 , which can be installed;
    β”‚ β”œβ”€ natcap.invest [3.10.1|3.10.2|…|3.14.1] would require
    β”‚ β”‚ └─ python >=3.8,<3.9.0a0 , which can be installed;
    β”‚ β”œβ”€ natcap.invest [3.10.1|3.10.2|…|3.14.3] would require
    β”‚ β”‚ └─ python >=3.9,<3.10.0a0 , which can be installed;
    β”‚ β”œβ”€ natcap.invest [3.10.2|3.11.0|…|3.14.3] would require
    β”‚ β”‚ └─ python >=3.10,<3.11.0a0 , which can be installed;
    β”‚ β”œβ”€ natcap.invest [3.14.2|3.14.3] would require
    β”‚ β”‚ └─ python >=3.12,<3.13.0a0 , which can be installed;
    β”‚ β”œβ”€ natcap.invest 3.14.3 would require
    β”‚ β”‚ └─ pygeoprocessing >=2.4.6 with the potential options
    β”‚ β”‚ β”œβ”€ pygeoprocessing [2.4.6|2.4.7] would require
    β”‚ β”‚ β”‚ └─ python >=3.10,<3.11.0a0 , which can be installed;
    β”‚ β”‚ β”œβ”€ pygeoprocessing [2.4.6|2.4.7] would require
    β”‚ β”‚ β”‚ └─ gdal >=3.0.4,<3.7.0 with the potential options
    β”‚ β”‚ β”‚ β”œβ”€ gdal [3.3.3|3.4.0|…|3.6.4], which can be installed (as previously explained);
    β”‚ β”‚ β”‚ β”œβ”€ gdal [3.0.4|3.1.0|…|3.6.0], which can be installed (as previously explained);
    β”‚ β”‚ β”‚ β”œβ”€ gdal [3.0.4|3.1.0|…|3.6.4], which can be installed (as previously explained);
    β”‚ β”‚ β”‚ β”œβ”€ gdal [3.1.3|3.1.4|…|3.6.4], which can be installed (as previously explained);
    β”‚ β”‚ β”‚ β”œβ”€ gdal [3.5.2|3.5.3|…|3.6.4], which can be installed (as previously explained);
    β”‚ β”‚ β”‚ β”œβ”€ gdal [3.0.4|3.1.0|…|3.3.2] would require
    β”‚ β”‚ β”‚ β”‚ └─ python >=3.6,<3.7.0a0 , which can be installed;
    β”‚ β”‚ β”‚ β”œβ”€ gdal [3.6.2|3.6.4] would require
    β”‚ β”‚ β”‚ β”‚ └─ python >=3.12,<3.13.0a0 , which can be installed;
    β”‚ β”‚ β”‚ β”œβ”€ gdal [3.6.0|3.6.2] would require
    β”‚ β”‚ β”‚ β”‚ └─ libgdal [3.6.0 h11d7215_0|3.6.2 h02ca117_2|…|3.6.2 he0cae08_9], which requires
    β”‚ β”‚ β”‚ β”‚ └─ zlib >=1.2.13,<1.3.0a0 , which can be installed;
    β”‚ β”‚ β”‚ └─ gdal 3.6.2 would require
    β”‚ β”‚ β”‚ └─ python >=3.13,<3.14.0a0 , which can be installed;
    β”‚ β”‚ β”œβ”€ pygeoprocessing [2.4.6|2.4.7] would require
    β”‚ β”‚ β”‚ └─ python >=3.12,<3.13.0a0 , which can be installed;
    β”‚ β”‚ β”œβ”€ pygeoprocessing [2.4.6|2.4.7] would require
    β”‚ β”‚ β”‚ └─ python >=3.9,<3.10.0a0 , which can be installed;
    β”‚ β”‚ β”œβ”€ pygeoprocessing 2.4.7 would require
    β”‚ β”‚ β”‚ └─ vc14_runtime >=14.29.30139 , which can be installed (as previously explained);
    β”‚ β”‚ └─ pygeoprocessing 2.4.7 would require
    β”‚ β”‚ └─ python >=3.13,<3.14.0a0 , which can be installed;
    β”‚ └─ natcap.invest 3.14.3 would require
    β”‚ └─ python >=3.13,<3.14.0a0 , which can be installed;
    β”œβ”€ pin-1 is not installable because it requires
    β”‚ └─ python 3.11.
    , which conflicts with any installable versions previously reported;
    β”œβ”€ vs2015_runtime 14.27.29016.
    is not installable because it conflicts with any installable versions previously repor;└─ zlib 1.3.1.
    is installable with the potential options
    β”œβ”€ zlib 1.3.1 conflicts with any installable versions previously reported;
    β”œβ”€ zlib 1.3.1 would require
    β”‚ └─ libzlib 1.3.1 h2466b09_1, which can be installed (as previously explained);
    β”œβ”€ zlib 1.3.1 would require
    β”‚ └─ libzlib 1.3.1 h2466b09_2, which can be installed (as previously explained);
    └─ zlib 1.3.1 would require
    └─ libzlib 1.3.1 hcfcfb64_0, which can be installed (as previously explained).

Hi @MartijnS , I don’t know much about the requirements for arcpy. It can certainly be a pain to install new packages with lots of requirements into an environment that already contains lots of packages with their own potentially conflicting requirements.

The easiest thing to do is usually start with a fresh environment. If you must have natcap.invest installed into the same environment as arcpy, then I guess I would try to follow my earlier suggestion, starting from your arcgis environment,

you could perhaps install all the dependencies of natcap.invest into that environment using conda. I would start with pygeoprocessing. Then as a final step, install natcap.invest using pip instead of conda: pip install natcap.invest --no-deps.

You can reference the list of dependencies and version restrictions here: invest/requirements.txt at main Β· natcap/invest Β· GitHub

Hi Dave, I think we’re almost there. The installation went well this time, but during the Python run, we’re still getting an error about not being able to find _gdal. Does this sound familiar to you?

Traceback (most recent call last):
File β€œC:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3-invest\Lib\site-packages\osgeo_init_.py”, line 30, in swig_import_helper
return importlib.import_module(mname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File β€œC:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3-invest\Lib\importlib_init_.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File β€œβ€, line 1204, in _gcd_import
File β€œβ€, line 1176, in _find_and_load
File β€œβ€, line 1147, in _find_and_load_unlocked
File β€œβ€, line 676, in _load_unlocked
File β€œβ€, line 573, in module_from_spec
File β€œβ€, line 1233, in create_module
File β€œβ€, line 241, in _call_with_frames_removed
ImportError: DLL load failed while importing _gdal: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File β€œf:\User\spoonm\python_workspace\python_test_code2.py”, line 11, in
import natcap.invest.urban_cooling_model
File β€œC:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3-invest\Lib\site-packages\natcap\invest_init_.py”, line 10, in
from osgeo import gdal
File β€œC:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3-invest\Lib\site-packages\osgeo_init_.py”, line 35, in
gdal = swig_import_helper()
^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3-invest\Lib\site-packages\osgeo_init
.py", line 32, in swig_import_helper
return importlib.import_module('gdal’)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3-invest\Lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named β€˜_gdal’
PS F:\User\spoonm\python_workspace>

Just to add to the previous, the path to this _gdal package exists in the folder: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3-invest\Lib\site-packages\osgeo.

Hi @Martijn , I appreciate your perseverance. It looks like you’re now dealing with challenges of installing GDAL into an ArcGIS python environment. That’s not something I’ve done before and you might get a better answer an ESRI-specific forum.

It’s possible that the arcgis python environment has packages installed from a different conda channel, like β€œdefaults”. And based on my earlier advice you may have been installing gdal from β€œconda-forge”. That sort of discrepancy might lead to a missing DLL error like you’re seeing, I’m not sure.

And indeed β€œconda-forge” is the only conda channel where you can get pygeoprocessing and natcap.invest. So there’s no easy solutions here. I would consider whether you truly need all these packages installed into the same environment. Perhaps you could run your invest models in one environment, and do your other scripted workflows that require arcpy in the arcgis environment?

1 Like