python-geoip does not work on python3.4?

user5331677 picture user5331677 · Sep 15, 2015 · Viewed 11.8k times · Source

I was able to get geolite2 working on python2.7 - but i needed 3.4. I found the instructions for 2.7 on this link: http://pythonhosted.org/python-geoip/. Code fragments are also provided.

pip install python-geoip
pip install python-geoip-geolite2
>>> from geoip import geolite2
>>> match = geolite2.lookup('17.0.0.1')
>>> match is not None
True

So I naturally changed all the pip to pip3 and installed on a fresh VM. There is no error on the code but it does not looup and return values from their db.

pip3 install python-geoip
pip3 install python-geoip-geolite2

In the 2.7 VM, when I used 3.4, I pointed the geoip lib at /usr/local/lib/python2.7/dist-packages - no luck either. It however works on 2.7 on the same VM.

What should I need to do to make it to work on 3.4?

Answer

Greg Oschwald picture Greg Oschwald · Sep 15, 2015

python-geoip does not support Python 3 and has not been updated in two years. Although there is a pull request to add Python 3 support, I would not expect it to be merged and released any time soon. I would recommend using the official MaxMind geoip2 package instead.