{"id":7270,"library":"google-geo-type","title":"Google Geo Type API Client Library","description":"The `google-geo-type` library provides Python protobuf definitions for common geographic types used across Google APIs, such as LatLng, Viewport, and PostalAddress. It is part of the larger `google-cloud-python` monorepo. Currently at version 0.6.0, it follows the release cadence of the Google Cloud client libraries, with updates typically bundled with other related packages.","status":"active","version":"0.6.0","language":"en","source_language":"en","source_url":"https://github.com/googleapis/google-cloud-python/tree/main/packages/google-geo-type","tags":["google-cloud","protobuf","geospatial","types"],"install":[{"cmd":"pip install google-geo-type","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"Early versions might have used a versioned path (e.g., 'v1') which is not present in the current unversioned structure.","wrong":"from google.geo.type.v1 import latlng_pb2","symbol":"latlng_pb2","correct":"from google.geo.type import latlng_pb2"},{"symbol":"viewport_pb2","correct":"from google.geo.type import viewport_pb2"},{"symbol":"postal_address_pb2","correct":"from google.geo.type import postal_address_pb2"}],"quickstart":{"code":"from google.geo.type import latlng_pb2\nfrom google.geo.type import viewport_pb2\n\n# Create a LatLng object\nlatitude = 34.052235\nlongitude = -118.243683\npoint = latlng_pb2.LatLng(latitude=latitude, longitude=longitude)\nprint(f\"Point: ({point.latitude}, {point.longitude})\")\n\n# Create a Viewport object\nviewport = viewport_pb2.Viewport(\n    low=latlng_pb2.LatLng(latitude=33.9, longitude=-118.3),\n    high=latlng_pb2.LatLng(latitude=34.1, longitude=-118.1)\n)\nprint(f\"Viewport Low: ({viewport.low.latitude}, {viewport.low.longitude})\")\nprint(f\"Viewport High: ({viewport.high.latitude}, {viewport.high.longitude})\")","lang":"python","description":"This quickstart demonstrates how to import and create instances of common geographic types like `LatLng` and `Viewport` using their respective protobuf definition modules."},"warnings":[{"fix":"Pin the library version in your `requirements.txt` (e.g., `google-geo-type==0.6.0`) and carefully test updates. Monitor the GitHub repository for official release notes.","message":"As a pre-GA (versions < 1.0.0) library, protobuf definitions within `google-geo-type` may introduce backward-incompatible changes without a major version bump. Always review release notes when upgrading.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Ensure your development and deployment environments use Python 3.9 or a newer compatible version. Upgrade Python if necessary.","message":"The library explicitly requires Python 3.9 or newer. Installing or running on older Python versions will result in an `ERROR: Package 'google-geo-type' requires a different Python; <your_version> not in '>=3.9'` during installation or runtime errors.","severity":"breaking","affected_versions":"All versions"},{"fix":"If you need to *call* a Google Geo API, ensure you install the appropriate client library (e.g., `google-maps-services-python`, `google-cloud-maps` for newer services) in addition to, or instead of, `google-geo-type` for types that are not part of the specific client library.","message":"This library provides only protobuf *definitions* (like `LatLng`, `Viewport`). It does not include client methods for interacting with specific Google Geo APIs (e.g., Geocoding API, Places API). For those, you'll need the respective Google Cloud client library.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Change the import statement to include `_pb2` at the end: `from google.geo.type import latlng_pb2`.","cause":"Incorrect import path. The protobuf definitions are found in modules ending with `_pb2`.","error":"ModuleNotFoundError: No module named 'google.geo.type.latlng'"},{"fix":"Upgrade your Python environment to version 3.9 or newer. Check your Python version with `python --version`.","cause":"Attempting to install or run the library with a Python version older than 3.9.","error":"ERROR: Package 'google-geo-type' requires a different Python; <your_version> not in '>=3.9'"},{"fix":"Ensure you are importing the specific protobuf definition module (e.g., `latlng_pb2`) and accessing the message class (e.g., `LatLng`) from *that* module: `from google.geo.type import latlng_pb2; point = latlng_pb2.LatLng(...)`.","cause":"Attempting to access a protobuf message directly from the `google.geo.type` module, or using the wrong casing/name.","error":"AttributeError: 'module' object has no attribute 'LatLng'"}]}