This is a Python module for reading MaxMind DB files, a binary file format that stores data indexed by IP address subnets (IPv4 or IPv6). The library includes both a pure Python reader and an optional C extension for performance. It is actively maintained, with version 3.1.1 released on March 5, 2026, and follows Semantic Versioning.
pip install maxminddbVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to open a MaxMind DB file using a context manager, perform IP lookups with `get()`, and retrieve database metadata. A valid MaxMind DB file (like a GeoLite2-City.mmdb) is required. Ensure the database file exists at the specified path or in the environment variable `MAXMIND_DB_PATH`.
Ensure all read operations are complete or synchronized before calling `reader.close()` or exiting a `with maxminddb.open_database(...)` block.
Validate IP addresses before lookup and ensure the database supports the IP version being queried (e.g., check `reader.metadata().ip_version`).
Manually close the file descriptor after passing it to `open_database` when using `Mode.FD`.
Obtain a valid MaxMind DB file and provide its path to `maxminddb.open_database()`.
Download the GeoLite2 database file from MaxMind's website (requires a free account) and ensure the path provided to `maxminddb.open_database()` is correct. The files often need to be decompressed with `gunzip` after download.
Re-download the MaxMind DB file to ensure it is complete and uncorrupted. Verify that the database file is compatible with the `maxminddb` library version being used.
Ensure the IP address string is valid and that you are not attempting to look up an IPv6 address in an IPv4-only database. For instance, if you have an IPv4-only database, convert IPv6 addresses to their IPv4-mapped equivalent if applicable, or use an IPv6-compatible database.
Install the package using pip: `pip install maxminddb`. If using a virtual environment, ensure it is activated before installation and execution.
No dependency data recorded yet.