Skip to content

Installation

Install from PyPI

leafmap is available on PyPI. To install leafmap, run this command in your terminal:

1
    pip install leafmap

Install from conda-forge

leafmap is also available on conda-forge. If you have Anaconda or Miniconda installed on your computer, you can install leafmap using the following command:

1
    conda install leafmap -c conda-forge

The leafmap package has an optional dependency - geopandas, which can be challenging to install on some computers, especially Windows. It is highly recommended that you create a fresh conda environment to install geopandas and leafmap. Follow the commands below to set up a conda env and isntall geopandas, xarray_leaflet, and leafmap.

1
2
3
4
5
6
    conda create -n geo python=3.8
    conda activate geo
    conda install geopandas
    conda install mamba -c conda-forge
    mamba install leafmap xarray_leaflet -c conda-forge
    pip install keplergl

Optionally, you can install some Jupyter notebook extensions, which can improve your productivity in the notebook environment. Some useful extensions include Table of Contents, Gist-it, Autopep8, Variable Inspector, etc. See this post for more information.

1
    conda install jupyter_contrib_nbextensions -c conda-forge

Install from GitHub

To install the development version from GitHub using Git, run the following command in your terminal:

1
    pip install git+https://github.com/giswqs/leafmap

Upgrade leafmap

If you have installed leafmap before and want to upgrade to the latest version, you can run the following command in your terminal:

1
    pip install -U leafmap

If you use conda, you can update leafmap to the latest version by running the following command in your terminal:

1
    conda update -c conda-forge leafmap

To install the development version from GitHub directly within Jupyter notebook without using Git, run the following code:

1
2
    import leafmap
    leafmap.update_package()

Troubleshooting

If the interactive map does not show up on Jupyter Notebook and JupyterLab, it is probably because the ipyleaflet extentsion is not installed properly. For example, you might receive an error message saying Error displaying widget: model not found. This a well-known issue related to ipyleaflet. See some relevant issues below.

Try some of the options below to resolve the issue. If the issue persists after trying these steps, you can open an issue on the ipyleaflet repository.

For Jupyter notebook, try running the following two commands within your leafmap conda environment:

1
2
jupyter nbextension install --py --symlink --sys-prefix ipyleaflet
jupyter nbextension enable --py --sys-prefix ipyleaflet

For JupyterLab, try running the following command within your leafmap conda environment:

1
jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-leaflet

Alternatively, you can run leafmap directly using binder:


Last update: 2021-10-19