MapLibre GL JS Python Bindings
raw JSON → 0.3.6 verified Fri May 01 auth: no python
Python bindings for MapLibre GL JS, enabling interactive web maps with vector tiles, custom styling, and geospatial data visualization. Current version 0.3.6 with frequent updates. Supports Python 3.9+.
pip install maplibre Common errors
error ImportError: cannot import name 'Map' from 'maplibre' ↓
cause Map class was renamed to MapLibre in v0.2.0.
fix
Replace
from maplibre import Map with from maplibre import MapLibre. error TypeError: 'MapLibre' object is not callable ↓
cause Instantiating MapLibre and then trying to call the instance as a function (e.g., `m = MapLibre(); m()`).
fix
Use
m.show() or other methods; do not call the instance directly. Warnings
breaking The Map class was renamed to MapLibre in v0.2.0; old code using `from maplibre import Map` will raise ImportError. ↓
fix Use `from maplibre import MapLibre` instead of `Map`.
gotcha Map does not automatically load in Jupyter notebooks without calling `m.show()` or using `%matplotlib notebook` magic. Without explicit display, the map appears as a blank output. ↓
fix Ensure you call `m.show()` at the end of your code.
gotcha Basemap enumeration values may have changed between releases; hardcoding names like 'CartoDB_Positron' may break if the enum is renamed or removed. Always use the Basemap enum from `maplibre.basemaps`. ↓
fix Import and use `Basemap` from `maplibre.basemaps` instead of string literals.
Imports
- MapLibre wrong
import maplibre; maplibre.MapLibrecorrectfrom maplibre import MapLibre - Map wrong
from maplibre import MagicMapcorrectfrom maplibre import Map
Quickstart
from maplibre import MapLibre
from maplibre.basemaps import Basemap
# Create a MapLibre instance and display a map
m = MapLibre()
m.add_basemap(Basemap.CartoDB_Positron)
m.show()