Search code examples
pythongeoipgeolite2

python-geoip does not work on python3.4?


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?


Solution

  • 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.