Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Lookup country code (iso 3166) by IP address.

Project Description


Lookup country code (iso 3166) by IP address.


$ pip install ip2country


$ python install

How to use

First: Implement IStore Interface

You must implement IStore interface in ip2country/

There is a sample implementation in example/store. This implementation is stored all records on the system memory.

Second: Store the records

store = Store()
parser = Parser(store)
with open(RECORD_FILE) as fp:

See examples/ for more detail.

Third: Lookup the IPAddress

store = Store()
record = store.lookup(IP_ADDRESS)
if record is None:
    print('Record not found')
    print('{0} is allocated to {1}'.format(IP_ADDRESS,

See examples/ for more detail.

Run the tests

$ tox


ip2country is licensed under the MIT LICENSE. See ./LICENSE.rst.

Release History

This version
History Node


History Node


Download Files

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

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(7.1 kB) Copy SHA256 Hash SHA256
2.7 Wheel May 20, 2014
(7.0 kB) Copy SHA256 Hash SHA256
3.3 Wheel May 20, 2014
(4.1 kB) Copy SHA256 Hash SHA256
Source May 20, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting