WSL 2 Ubuntu installation environment setup and daily workflow

Purpose. This guide prepares a Windows computer for the flood forecasting workshop. It installs WSL 2 and Ubuntu, installs Micromamba inside Ubuntu, creates the cpc_id_env Python environment, installs TensorFlow, and verifies the required AI libraries.

System requirement. Windows 11 or Windows 10 version 2004 or later. An internet connection and administrator access are required.

1. Install WSL and Ubuntu

Open the Start menu, search for PowerShell, right-click Windows PowerShell, and select Run as administrator.

Run in Administrator PowerShell

wsl --install

Restart the computer when Windows requests it. The standard installation enables WSL and installs Ubuntu.

If Ubuntu was not installed

Return to Administrator PowerShell and run these commands to view and install available distributions.

Run in Administrator PowerShell

wsl --list --online
wsl --install -d Ubuntu

2. Open and Configure Ubuntu

Open the Start menu, search for Ubuntu, and launch it. On the first launch, wait for setup to finish, then create a Linux username and password.

Password note. Nothing appears on the screen while typing the Linux password. This is normal. Type it carefully and press Enter.

3. Update Ubuntu Tools

Run the following commands inside the Ubuntu window. Enter the Linux password if prompted.

Run in Ubuntu

sudo apt update
sudo apt install -y curl bzip2

4. Install Micromamba

Copy the complete command into Ubuntu and press Enter.

Run in Ubuntu

curl -L https://micro.mamba.pm/install.sh | bash

Installation responses

Prompt Response
Micromamba binary folder [~/.local/bin] Press Enter
Init shell bash [Y/n] Type Y, then press Enter
Configure conda forge [Y/n] Type Y, then press Enter
Prefix location [~/micromamba] Press Enter - do not type Y

5. Activate and Check Micromamba

Load the updated Bash configuration and confirm that Micromamba returns a version number.

Run in Ubuntu

source ~/.bashrc
micromamba --version

6. Create the AI Environment

Create the Python 3.10 environment and install the required scientific, geospatial, plotting, and machine learning packages.

Run in Ubuntu

micromamba create -n cpc_id_env -c conda-forge python=3.10 numpy pandas geopandas shapely jupyter scipy matplotlib scikit-learn netcdf4 h5py cartopy xarray seaborn pip -y

7. Activate the Environment

Activate the environment. The Ubuntu prompt should begin with (cpc_id_env).

Run in Ubuntu

micromamba activate cpc_id_env

8. Upgrade pip and Install TensorFlow

Keep cpc_id_env activated, then upgrade pip and install TensorFlow.

Run in Ubuntu

python -m pip install --upgrade pip
python -m pip install tensorflow

9. Verify the AI Libraries

Run this single command after TensorFlow finishes installing.

Run in Ubuntu

python -c "import numpy as np; import pandas as pd; from sklearn.preprocessing import MinMaxScaler; from keras.models import Sequential; from keras.layers import LSTM, Dense; print('Everything works!')"

Successful result. If Ubuntu prints Everything works!, the AI environment is ready.

Daily Flood Forecasting Workflow

Use these steps each time you return to the flood forecasting project.

1 Open Ubuntu

Open Ubuntu from the Windows Start menu.

2 Activate the environment

Run in Ubuntu

micromamba activate cpc_id_env

3 Go to the project folder

Run in Ubuntu

cd /mnt/c/Users/ehsan/Downloads/flood/flood

4 Check the files

Run in Ubuntu

ls

5 Run the model

Run in Ubuntu

python flood_forecast_realtime_multiple.py

Useful Checks

Check WSL status in PowerShell

wsl --status

Check installed Linux distributions in PowerShell

wsl --list --verbose

List Micromamba environments in Ubuntu

micromamba env list

Exit the active environment in Ubuntu

micromamba deactivate