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 some optional dependencies (e.g., geopandas and localtileserver), 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 install geopandas, localtileserver, keplergl, pydeck, and leafmap.

1
2
conda install -n base mamba -c conda-forge
mamba create -n geo leafmap geopandas localtileserver python -c conda-forge

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/opengeos/leafmap

Use docker

You can also use docker to run leafmap:

1
docker run -it -p 8888:8888 giswqs/leafmap:latest

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 extension 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: