skillfed

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.

ip2location v8.11.0 394.8K downloads/30d#6,987 on PyPI165
Permissive license AGING released

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 ip2location

uv

uv add ip2location

poetry

poetry add ip2location

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python Modules

Tags

ip geolocation lookupip address to locationfind city from ipipv4 ipv6 geolocationip to country region citygeoip database queryip location database
geolocationip-lookupoffline-database

More Python Modules packages