Installing InVEST From Source

Attention

Most users will want to install the InVEST app (Mac disk image or Windows installer) from the InVEST download page. The instructions here are for more advanced use cases.

Binary Dependencies

InVEST itself depends only on python packages, but many of these package dependencies depend on low-level libraries or have complex build processes. Some of these packages (notably, numpy and scipy) have started to release precompiled binary packages of their own. Recently we have had success installing all dependencies through conda and pip; however you may find it easier to install some through a system package manager.

Conda

If you’re using a conda environment to manage your natcap.invest installation, it’s easiest to install a few binary packages first before using pip to install the rest:

$ conda install "gdal>=3" numpy shapely rtree
$ pip install natcap.invest

System Package Managers

Linux

Linux users have it easy, as almost every package required to use natcap.invest is available in the package repositories. The provided commands will install only the libraries and binaries that are needed, allowing pip to install the rest.

Ubuntu & Debian

Attention

The package versions in the debian:stable repositories often lag far behind the latest releases. It may be necessary to install a later version of a library from a different package repository, or else build the library from source.

$ sudo apt-get install python3-dev python3-setuptools python3-gdal python3-rtree python3-shapely

Fedora

$ sudo yum install python3-devel python3-setuptools python3-gdal python3-rtree python3-shapely

Mac OS X

The easiest way to install binary packages on Mac OS X is through a package manager such as Homebrew:

$ brew install gdal spatialindex pyqt

The GDAL and PyQt packages include their respective python packages. The others will allow their corresponding python packages to be compiled against these binaries via pip.

Windows

While many packages are available for Windows on the Python Package Index, some may need to be fetched from a different source. Many are available from Christogh Gohlke’s unofficial build page: http://www.lfd.uci.edu/~gohlke/pythonlibs/

PyQt4 installers can also be downloaded from the Riverbank Computing website.

Python Dependencies

Dependencies for natcap.invest are listed in requirements.txt:

#
# Any lines with "# pip-only" at the end will be processed by
# scripts/convert-requirements-to-conda-yml.py as though it can only be found
# on pip.

GDAL>=3.1.2,!=3.3.0  # 3.3.0 had a bug that broke our windows builds: https://github.com/OSGeo/gdal/issues/3898
Pyro4==4.77  # pip-only
pandas>=1.2.1
numpy>=1.11.0,!=1.16.0
Rtree>=0.8.2,!=0.9.1
Shapely>=1.7.1,<2.0.0
scipy>=1.6.0  # pip-only
pygeoprocessing>=2.3.2  # pip-only
taskgraph[niced_processes]>=0.10.3  # pip-only
psutil>=5.6.6
chardet>=3.0.4
openpyxl

Optional Qt User Interface

InVEST’s user interface is built with PyQt. Because of the hefty binary requirement of Qt and the relative difficulty of installing PyQt, these dependencies will not be installed with the standard pip install natcap.invest. These dependencies are available as extras, however, and can be installed via pip:

$ pip install natcap.invest[ui]

Installing from Source

Note

Python 3.6 users will need to install Microsoft Visual Studio 2017, or at least the Build Tools for Visual Studio 2017. See the python wiki page on compilation under Windows for more information.

Assuming you have a C/C++ compiler installed and configured for your system, and dependencies installed, the easiest way to install InVEST as a python package is:

$ pip install natcap.invest

Installing the latest development version

Pre-built binaries for Windows

Pre-built installers and wheels of development versions of natcap.invest for 32-bit Windows python installations are available from http://releases.naturalcapitalproject.org/?prefix=invest/, along with other distributions of InVEST. Once downloaded, wheels can be installed locally via pip.

Installing from our source tree

The latest development version of InVEST can be installed from our git source tree if you have a compiler installed:

$ pip install "git+https://github.com/natcap/invest@main#egg=natcap.invest"