Registry / maps / google-maps-routeoptimization

google-maps-routeoptimization

JSON →
library0.5.0pypypi✓ verified 83d ago

Client library for the Google Maps Route Optimization API (v0.5.0). Optimizes vehicle routes for fleet scheduling, with support for constraints like time windows, capacities, and breaks. Released monthly.

pip install google-maps-routeoptimization
INSTALL
IMPORT
SIG · GOOGLE-MAPS-ROUTEO
G
google-maps-routeoptimization
mapspythonv0.5.0
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.

RouteOptimizationClient
from google.maps import routeoptimization_v1
from google.cloud import routeoptimization_v1
Package lives under google.maps, not google.cloud.

Initialize client and call optimize_tours with a minimal model.

from google.maps import routeoptimization_v1 client = routeoptimization_v1.RouteOptimizationClient() parent = "projects/" + (os.environ.get("GOOGLE_CLOUD_PROJECT", "")) request = routeoptimization_v1.OptimizeToursRequest( parent=parent, model={ "vehicles": [ { "start_location": {"latitude": 37.7749, "longitude": -122.4194}, "end_location": {"latitude": 37.7849, "longitude": -122.4094}, } ], "shipments": [ { "pickups": [{"arrival_location": {"latitude": 37.7749, "longitude": -122.4194}}], "deliveries": [{"arrival_location": {"latitude": 37.7849, "longitude": -122.4094}}], } ], }, ) response = client.optimize_tours(request) print(response)
Debug
Known issues
breakingAll route optimization classes live under google.maps.routeoptimization_v1 (note: plural 'routeoptimization', no hyphen). Do not use google.cloud or google.maps.routeoptimization.
fix
Import as: from google.maps import routeoptimization_v1
affects: >=0.1.0
breakingThe client class is 'RouteOptimizationClient', not 'RoutesOptimizationClient' or 'RoutingOptimizationClient'.
fix
Use: routeoptimization_v1.RouteOptimizationClient()
affects: >=0.1.0
gotchaThe 'parent' parameter must follow the pattern 'projects/{project_id}/locations/{location_id}'. A common mistake is omitting the location suffix (e.g., just 'projects/123').
fix
Use: parent = f"projects/{project}/locations/global"
affects: >=0.1.0
gotchaThe library requires Python >=3.10. Users on older Python will get a version conflict.
fix
Upgrade Python to 3.10+ or use an older version of the library (if available).
affects: >=0.5.0
deprecatedThe 'OptimizeToursRequest.model' field expects a dict, not a proto Message object in some older versions. In v0.5.0, both work but dict is preferred.
fix
Use dict for the model field to avoid potential serialization issues.
affects: 0.3.0 - 0.5.0
Errors
Common errors & fixes
ImportError: cannot import name 'RouteOptimizationClient' from 'google.cloud'
Incorrect import path; the package is under google.maps, not google.cloud.
fix
Use: from google.maps import routeoptimization_v1; client = routeoptimization_v1.RouteOptimizationClient()
ModuleNotFoundError: No module named 'google.maps.routeoptimization'
The package name has no hyphen when imported; also typo of 'routeoptimization' vs 'routeoptimization_v1'.
fix
Install with pip install google-maps-routeoptimization, then import as from google.maps import routeoptimization_v1
TypeError: optimize_tours() missing 1 required positional argument: 'request'
Calling method incorrectly; the new API requires an OptimizeToursRequest object.
fix
Create a request object: request = routeoptimization_v1.OptimizeToursRequest(parent=..., model=...); client.optimize_tours(request=request)
google.api_core.exceptions.InvalidArgument: 400 The parent resource name is invalid.
The 'parent' parameter does not include a location (e.g., '/locations/global').
fix
Set parent to something like 'projects/my-project/locations/global'.
Upgrade
Version history
0.5.0latest on PyPI · released Jun 3, 2026
Audit
Dependencies
google-api-corerequiredRequired by Google Cloud client libraries for transport and error handling.
google-authrequiredHandles authentication (service account, ADC).
proto-plusrequiredProtobuf message handling.
Agent activity
42 hits · last 30 days
node
38
OpenAI (training)
1
Resources
google-maps-routeoptimization — pip install google-maps-routeoptimization · libregistry