Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

An offline tool to get country by IP

Project description

An offline tool to get country by IP


  • Python >= 3.6


  1. Download IP2Location database for IPv4 from
  2. Install library:

pip install ip_country


>>> from pprint import pprint
>>> from ip_country import IPCountry
>>> ip = IPCountry('/path/to/ipdb.csv')
>>> ip_data = ip.get_ip_data('')
>>> pprint(ip_data)
{'city_name': 'Melbourne',
 'country_code': 'AU',
 'country_name': 'Australia',
 'error': None,
 'ip': '',
 'region_name': 'Victoria'}

>>> ip_data = ip.get_ip_data('blah.73.96.0')
>>> pprint(ip_data)
{'error': "Only decimal digits permitted in 'blah' in 'blah.73.96.0'",
 'ip': 'blah.73.96.0'}

Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ip-country, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size ip_country-1.0.0-py3-none-any.whl (3.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page