Landlab developer install on Windows (with gcc)

Building Landlab from source on Windows is trickier than on Linux or macOS. Below are some steps, based on recent experience, that should work. Please let me know if you find any problems.

Install Miniforge

To set up a Python environment for building, running, and modifying Landlab, we use Miniforge. Download the Windows installer for Miniforge and run it.

During installation, be sure to select these three options:

  • “Create shortcuts”
  • “Add Miniforge3 to my PATH environment variable” (even though a warning is given against this)
  • “Register Miniforge as my default Python”

We’ll use the Miniforge Prompt, which is installed in the Windows Start menu, for the next steps.

Create a conda environment

Through the Miniforge prompt, use conda to create a virtual environment for the Landlab developer install.

conda create -y -n landlab_dev python pip gcc git

Landlab has many parts that are written in C, so we need a C compiler and linker to build them. These are provided by gcc. We also install git, pip, and python, all of which we’ll use below.

Activate the new environment.

conda activate landlab_dev

Clone the Landlab repository

From the Miniforge prompt, use git to clone the Landlab repository to your computer.

git clone git@github.com:landlab/landlab.git

You may wish to fork Landlab and clone your fork instead. You’ll need an SSH key pair set up on your computer for communicating with GitHub. See this lesson from CSDMS Ivy for more information.

The cloned repository lives in a directory called landlab. Change to this directory.

cd landlab

Install Landlab into the conda environment

From the Miniforge prompt, in the landlab directory with the activated landlab_dev environment, build Landlab from source and install it with pip.

pip install -e ".[dev.testing]"

Check that Landlab is installed by starting a Python session from the Miniforge prompt.

python

In the Python session, import the landlab package and check its version.

>>> import landlab
>>> landlab.__version__
'2.10.2.dev0'

[Optional] Try the Landlab tutorials

The Landlab repository comes with a large number of Jupyter notebook tutorials that you can run through the landlab_dev environment. They require a few extra dependencies, though. Install them first with:

pip install -r notebooks/requirements.in

Then start JupyterLab to access and run the notebooks:

jupyter lab docs/source/tutorials
1 Like