In [1]:
import pygeoip

In [2]:
gi = pygeoip.GeoIP('/usr/share/GeoIP/GeoIP.dat', pygeoip.MEMORY_CACHE)

In [3]:
>>> gi.country_code_by_name('google.com')


Out[3]:
'US'

In [4]:
>>> gi.country_code_by_addr('64.233.161.99')


Out[4]:
'US'

In [5]:
>>> gi.country_name_by_addr('64.233.161.99')


Out[5]:
'United States'

In [6]:
>>> gi = pygeoip.GeoIP('/usr/share/GeoIP/GeoIPRegion.dat')


---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-6-2966d447e099> in <module>()
----> 1 gi = pygeoip.GeoIP('/usr/share/GeoIP/GeoIPRegion.dat')

/home/doj/i/env3/lib/python3.4/site-packages/pygeoip/__init__.py in __init__(self, filename, flags, cache)
    116             f.close()
    117         else:
--> 118             self._fp = codecs.open(filename, 'rb', ENCODING)
    119             self._type = 'STANDARD'
    120 

/usr/lib/python3.4/codecs.py in open(filename, mode, encoding, errors, buffering)
    889         # Force opening of the file in binary mode
    890         mode = mode + 'b'
--> 891     file = builtins.open(filename, mode, buffering)
    892     if encoding is None:
    893         return file

FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/GeoIP/GeoIPRegion.dat'

In [ ]:
>>> gi.region_by_name('apple.com')