Install & Compatibility
Where this runs
tested against v0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 2.4s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ReverseGeocoder
✓ from nominatim import ReverseGeocoder
✗ from geopy.geocoders import Nominatim
The 'nominatim' package is distinct from 'geopy' which is a modern geocoding library including Nominatim support. The legacy 'nominatim' package is for a self-hosted or local Nominatim instance, not the official public API via geopy.
This quickstart demonstrates how to use the legacy `nominatim` library to perform reverse geocoding against a *local or self-hosted* Nominatim instance. It highlights the `ReverseGeocoder` class and its `geocode` method. Due to the library's age, the example uses Python 2.7 print syntax and explicitly warns that for modern applications, especially those using the public Nominatim API, `geopy` is the recommended alternative.
import os
from nominatim import ReverseGeocoder
# This legacy library is designed to connect to a self-hosted Nominatim instance.
# The URL would point to your local Nominatim reverse.php endpoint.
# For public Nominatim API, use the 'geopy' library instead.
# Example for a local/self-hosted Nominatim (requires a running Nominatim PHP frontend)
# Note: This code uses Python 2.7 print syntax and assumes a local Nominatim setup.
# To run on modern Python, this example would need significant modification.
try:
# Assuming a local Nominatim installation available at this URL
# The actual URL might vary based on your Nominatim server setup.
# This is illustrative for the *original* library's intended use.
nominatim_url = os.environ.get('NOMINATIM_LOCAL_URL', 'http://127.0.0.1/nominatim/reverse.php?format=json')
client = ReverseGeocoder(nominatim_url)
# Example coordinates (Melbourne, Australia)
latitude = -37.856206
longitude = 145.233980
print(f"Attempting to reverse geocode {latitude}, {longitude} using legacy nominatim library...")
response = client.geocode(latitude, longitude)
if response and 'full_address' in response:
print(f"Full Address: {response['full_address']}")
elif response:
print(f"Raw response (no 'full_address'): {response}")
else:
print("No response or error from Nominatim.")
except ImportError:
print("Error: The 'nominatim' library is not installed or requires Python 2.7.")
except Exception as e:
print(f"An error occurred: {e}")
# For modern Python and public Nominatim API, consider geopy:
# from geopy.geocoders import Nominatim
# geolocator = Nominatim(user_agent="my-app-name")
# location = geolocator.reverse("52.509669, 13.376294")
# print(location.address)
Debug
Known issues
breakingThis library is designed for Python 2.7. Using it with Python 3 will result in `ImportError` or `SyntaxError` due to incompatible language features (e.g., `print` statement vs. function, module structure).fixUse a Python 2.7 environment or migrate to modern alternatives like `geopy` (for public Nominatim API) or `nominatim-api` (for local Nominatim database access).
affects: All versions (0.1) on Python 3.x
deprecatedThe `nominatim` package (v0.1) has not been updated since 2014 and is considered abandoned. It targets a potentially outdated Nominatim API endpoint (PHP frontend) and is not compatible with current Nominatim server versions without significant modification.fixAvoid using this library for new projects. For web service interaction, use `geopy`. For local Nominatim database interaction, use `nominatim-api` and `nominatim-db`.
affects: 0.1
gotchaThis library is distinct from the current official Nominatim Python frontend packages (`nominatim-api`, `nominatim-db`) and `geopy`. It is *not* for querying `nominatim.openstreetmap.org` directly, but rather for a self-hosted instance.fixCarefully review your project requirements. If you need to query the public Nominatim service, use `geopy`. If you need to build and query a local Nominatim database, refer to `nominatim-api` and `nominatim-db` documentation.
affects: All versions (0.1)
Errors
Common errors & fixes
ImportError: No module named nominatim
Attempting to install or import 'nominatim' on a system where pip is linked to Python 3, or the package cannot be found due to being very old/unmaintained.
fixEnsure you are using a Python 2.7 environment for installation and execution. For modern Python, consider `pip install geopy` and use its Nominatim geocoder instead.
TypeError: 'str' object is not callable (related to print statement)
Running Python 2.7 code (e.g., `print response`) in a Python 3 environment. The legacy `nominatim` library uses Python 2.7 syntax.
fixExecute the code in a Python 2.7 interpreter. Alternatively, rewrite the code to conform to Python 3 syntax (`print(response)`), though other incompatibilities may still arise.
HTTPSConnectionPool(host='your_nominatim_host', port=443): Max retries exceeded with url: ... (Caused by ReadTimeoutError("..."))
The legacy library might have issues with modern SSL certificates, network configurations, or the target Nominatim server (if self-hosted) is not responding or configured correctly.
fixVerify the reachability and configuration of your self-hosted Nominatim server. For public Nominatim services, switch to a modern library like `geopy` which handles network requests and SSL more robustly. Ensure your `user_agent` is set correctly and observe usage policies if using public APIs.
Upgrade
Version history
0.1latest on PyPI · released Oct 19, 2014
Audit
Dependencies
simplejsonrequiredRequired for JSON parsing, as specified in the original setup.py for Python 2.7.
Resources
No resource links recorded.