Registry / data / python-geoip

python-geoip

JSON →
library1.2pypypi✓ verified 86d ago

Provides GeoIP functionality for Python. Version 1.2 is the last release, unmaintained since 2011. It wraps the MaxMind GeoIP legacy C library. Use python-geoip-geolite2 or geoip2 for modern MaxMind databases.

pip install python-geoip
INSTALL
IMPORT
SIG · PYTHON-GEOIP
P
python-geoip
datapythonv1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GeoIP
from geoip import geolite2
from geoip import GeoIP
GeoIP class was removed; geolite2 provides lookup functions.
geolite2
from geoip import geolite2
import geolite2
geolite2 is a submodule of geoip, not a top-level package.

Look up IP address using GeoLite2 database (requires python-geoip-geolite2).

from geoip import geolite2 match = geolite2.lookup('8.8.8.8') if match: print(match.country) print(match.continent) print(match.timezone) else: print('No match')
Debug
Known issues
deprecatedpython-geoip 1.2 is unmaintained; uses legacy GeoIP databases. GeoLite2 databases will not work.
fix
Use python-geoip-geolite2 or geoip2 library.
affects: 1.2
breakingThe GeoIP class and the 'from geoip import GeoIP' pattern no longer exist in newer versions.
fix
Import geolite2: from geoip import geolite2
affects: >=1.3 (if ever released) or when using python-geoip-geolite2
gotchaRequires separate GeoIP C library and database files. Database file path must be set via environment variable or manually.
fix
Install libgeoip-dev and download GeoIP.dat from MaxMind legacy site.
affects: 1.2
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'geoip'
python-geoip not installed or imported incorrectly.
fix
pip install python-geoip or use python-geoip-geolite2.
AttributeError: module 'geoip' has no attribute 'geolite2'
python-geoip-geolite2 not installed; only base python-geoip is installed.
fix
pip install python-geoip-geolite2
TypeError: lookup() missing 1 required positional argument: 'ip'
Using geolite2.lookup incorrectly (e.g., geolite2.lookup()).
fix
Call geolite2.lookup('8.8.8.8') with an IP string.
Upgrade
Version history
1.2latest on PyPI · released Feb 21, 2014
Audit
Dependencies
GeoIP (C library)requiredCore dependency for database lookup
python-geoip-geolite2optionalAlternative for GeoLite2 databases (no C library needed)
Agent activity
7 hits · last 30 days
node
6
Resources
python-geoip — pip install python-geoip · libregistry