However, I ran both pip and Conda commands and am still not able to install InVEST. After running pip natcap.invest the installation fails with the GDAL dependency.
Here is a part of my error message:
ERROR: Command errored out with exit status 1: /home/username/software-tools/anaconda3/envs/Python37/bin/python -u -c βimport sys, setuptools, tokenize; sys.argv[0] = β"β"β/tmp/pip-install-vq1fhgi6/gdal_c5836a2f273c4c4ab26554c66a794416/setup.pyβ"β"β; file=β"β"β/tmp/pip-install-vq1fhgi6/gdal_c5836a2f273c4c4ab26554c66a794416/setup.pyβ"β"β;f=getattr(tokenize, β"β"βopenβ"β"β, open)(file);code=f.read().replace(β"β"β\r\nβ"β"β, β"β"β\nβ"β"β);f.close();exec(compile(code, file, β"β"βexecβ"β"β))β install --record /tmp/pip-record-3y_dmg70/install-record.txt --single-version-externally-managed --compile --install-headers /home/username/software-tools/anaconda3/envs/Python37/include/python3.7m/GDAL Check the logs for full command output.
It can certainly be a pain to get set up with an InVEST development environment. We recommend using miniconda to setup environments via the command line: https://docs.conda.io/en/latest/miniconda.html
With conda setup you can create a new conda environment:
conda create -p ./my-new-env python=3.8
Then we can activate that environment:
conda activate ./my-new-env
From there we can install our dependencies:
conda install gdal rtree shapely numpy cython
Then we should be able to grab InVEST from pip
pip install natcap.invest
Hopefully this helps get you set up! Let us know what other issues come up and we can step through them.
Thanks for the prompt reply. Iβve tried the recommended commands and once I run the last command using pip for the install of InVEST, I get the error message:
ERROR: Command errored out with exit status 1: /home/username/Desktop/Korotu/Korotu_Drafts/TESTNATCAP/bin/python -u -c βimport sys, setuptools, tokenize; sys.argv[0] = β"β"β/tmp/pip-install-98hxz40_/gdal_50e6798712d143f79e51100ca63cf1f5/setup.pyβ"β"β; file=β"β"β/tmp/pip-install-98hxz40_/gdal_50e6798712d143f79e51100ca63cf1f5/setup.pyβ"β"β;f=getattr(tokenize, β"β"βopenβ"β"β, open)(file);code=f.read().replace(β"β"β\r\nβ"β"β, β"β"β\nβ"β"β);f.close();exec(compile(code, file, β"β"βexecβ"β"β))β install --record /tmp/pip-record-zxbvmwev/install-record.txt --single-version-externally-managed --compile --install-headers /home/username/Desktop/Korotu/Korotu_Drafts/TESTNATCAP/include/python3.8/GDAL Check the logs for full command output.
I believe the error is still the same as before with installing GDAL
Could you do a quick gdalinfo --version within your activated conda environment and let us know which GDAL version is installed?
InVEST expects a specific version of GDAL, and if it canβt find it, pip install will attempt to build it from source, which is probably what weβre seeing here.
In case this is whatβs happening, could you try this?
and it doesnβt seem to work on my conda environment. However, I do know that the current version of GDAL I have installed is 3.0.2. After trying to run the command
conda install -c conda-forge gdal rtree shapely numpy cython
and
pip install natcap.invest
I get the same error as before: ERROR: Command errored out with exit status 1: /home/username/Desktop/Korotu/Korotu_Drafts/TESTNATCAP/bin/python -u -c βimport sys, setuptools, tokenize; sys.argv[0] = β"β"β/tmp/pip-install-98hxz40_/gdal_50e6798712d143f79e51100ca63cf1f5/setup.pyβ"β"β; file =β"β"β/tmp/pip-install-98hxz40_/gdal_50e6798712d143f79e51100ca63cf1f5/setup.pyβ"β"β;f=getattr(tokenize, β"β"βopenβ"β"β, open)( file );code=f.read().replace(β"β"β\r\nβ"β"β, β"β"β\nβ"β"β);f.close();exec(compile(code, file , β"β"βexecβ"β"β))β install --record /tmp/pip-record-zxbvmwev/install-record.txt --single-version-externally-managed --compile --install-headers /home/username/Desktop/Korotu/Korotu_Drafts/TESTNATCAP/include/python3.8/GDAL Check the logs for full command output.
As a side note, I noticed that as I was trying to install GDAL within my conda environment, it does not support Python version 3.9. However, it does support python version 3.8 and 3.7
Ah, thatβll be the issue, then. InVEST requires GDAL >= 3.1.2, so when pip canβt find a version of GDAL matching the requirement, it tries to install it locally.
Thatβs correct, though Iβm sure GDAL will update their conda packages in due time. But itβs also worth noting that InVEST is only currently tested against python 3.7 and 3.8. Could you try downgrading your conda environment python to 3.8 and reinstalling?