Install Anaconda if it is not already available on your system (I recommend the lightweight Miniconda). On Arch Linux, it can be installed from the AUR:

yay -Syu miniconda3

To set up an Anaconda virtual environment with the required tools (QGIS, Python, or R), save the snippet under the relevant section as a YAML file (e.g. environment.yml). Then, run the following commands, replacing ${envname} with the name of the environment as defined in the first line of the YAML file:

conda env create --file environment.yml
conda activate ${envname}

All of these packages can be installed in a single Anaconda virtual environment via the conda-forge channel (though I haven’t checked to see if there are potential conflicts).


name: qgis
  - conda-forge
  - defaults
  - python=3
  - qgis


name: py-geo
  - conda-forge
  - anaconda
  - python=3
  - geopandas
  - rioxarray
  - rasterstats
  - scipy
  - cfgrib
  - netcdf4
  - cdo  # unavailable on Windows; use Conda with WSL
  - dask  # parallel computing
  - pooch  # to download data
  - matplotlib  # plotting tools
  - matplotlib_scalebar
  - nc-time-axis
  - seaborn
  - cartopy
  - mapclassify
  - contextily
  - pyviz
  - hvplot
  - statsmodels
  - jupyterlab  # interactive notebooks
  - jupyter_bokeh
  - pytest  # testing and linting
  - flake8
  - pylint
  - black
  - black-jupyter


See this post for more information about setting up R to use with JupyterLab in an Anaconda environment.

name: r-geo
  - conda-forge
  - r
  - anaconda
  - r-base
  - r-essentials
  - libgit2  # to install packages from Git repositories
  - r-devtools
  - r-terra
  - r-rgdal
  - r-sf
  - r-geojsonio
  - r-rgeos
  - r-rastervis
  - jupyterlab