IP2Location
This is an IP geolocation library that enables the user to find the country, region, city, latitude and longitude, ZIP code, time zone, ISP, domain name, area code, weather info, mobile info, elevation, usage type, address type and IAB category from an IP address. It supports both IPv4 and IPv6 lookup.
What it is and what it does
IP2Location is a Python library for IP geolocation lookups that reads from binary database files to return detailed location and network information for both IPv4 and IPv6 addresses. It extracts country, region, city, coordinates, ISP, timezone, domain, area code, weather station data, mobile carrier codes, elevation, usage type, and IAB category from a single IP query.
The library has no runtime dependencies and supports Python 3.5 through 3.13 on CPython and PyPy. To use it, you download a BIN database file from IP2Location (free LITE or commercial versions), then instantiate the library with that file path and call query methods. It's a straightforward wrapper around binary database lookups, so the main constraint is obtaining and maintaining the database file separately.
Use it for:
- Geoblock content or services by country or region based on user IP addresses.
- Enrich user analytics with location, ISP, and network type information.
- Detect and flag suspicious login attempts from unexpected geographic regions.
- Route requests to regional servers or CDN nodes based on client IP location.
- Populate user profiles with inferred timezone and language preferences from IP.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Looks up geolocation data (country, region, city, latitude/longitude, ISP, timezone, and more) from an IP address or hostname by querying an IP2Location BIN database file.
Yes, if you need IP geolocation and are willing to manage a separate BIN database file. The library is stable, has no dependencies, and covers a broad range of lookup fields. The main trade-off is that you must download and maintain the database yourself; it's not a live API service. Maintenance is aging but the repository remains active and there are no known vulnerabilities.
Install
ip2location on PyPI
pip
pip install ip2locationuv
uv add ip2locationpoetry
poetry add ip2locationInstalling IP2Location
Before you install
Installs with no runtime dependencies and low friction. Last release was 344 days ago; the repository is active and not archived, though maintenance appears to be slowing.
License in practice
Licensed under MIT (permissive), so you can use, modify, and distribute the library freely in commercial and private projects with minimal restrictions.
Quickstart
pip install ip2location
import ip2location
db = ip2location.IP2Location()
db.open('path/to/IP2LOCATION-LITE-DB5.BIN')
result = db.query_by_ip_address('8.8.8.8')
You must download an IP2Location BIN database file separately (free LITE versions available at lite.ip2location.com or commercial versions at ip2location.com) before queries will work.
Verify before relying
- Whether the library actively maintains compatibility with Python versions beyond 3.13.
- Performance characteristics when querying very large numbers of addresses.
- Whether BIN database updates are automatic or require manual download and replacement.
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 344 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 394,765/month — #6,987 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ip2location-8.11.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
geoip2fastGeoIP2Fast performs fast geolocation lookups…
permissive · top 15,000 on PyPI
ip3countryLooks up the ISO 3166-1 alpha-2 country code…
permissive · top 5,000 on PyPI
ipinfoQueries the IPinfo.io API to retrieve…
permissive · top 15,000 on PyPI
walkscore-apiProvides Python bindings to query the WalkScore…
permissive · top 15,000 on PyPI
maxminddb-geolite2Provides geolocation lookups by IP address…
unclear · top 15,000 on PyPI
maxminddbReads MaxMind DB files to look up geolocation…
permissive · top 5,000 on PyPI
ipwhoisRetrieves and parses whois and RDAP data for…
permissive · top 15,000 on PyPI
geoip2Queries MaxMind's GeoIP web services and…
permissive · top 5,000 on PyPI
placekeyConverts between Placekeys (location…
permissive · top 15,000 on PyPI
geoip2-toolsAutomates downloading and updating of MaxMind…
permissive · top 15,000 on PyPI