Using Ubuntu 14.04 following this tutorial https://www.youtube.com/watch?v=PzkHU5GM8_E
Updated by these instructions to use the Client class https://stackoverflow.com/a/27294555/5619635
sudo apt-get install python-pip
pip install -U googlemaps
python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from googlemaps import Client
>>> mapService = Client()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/googlemaps/client.py", line 101, in __init__
raise ValueError("Must provide API key or enterprise credentials "
ValueError: Must provide API key or enterprise credentials when creating client.
I have an API key from the Google developer console. How do I the API key value in pyton?
--
Edit: Tried the solution provided by skycrew but now getting the error that googlemaps is not a supported API project.
>>> import googlemaps
>>> from googlemaps import Client
>>> mapService = Client("AInotqjpmyvA7realBIy-keymA9u0")
>>> directions = mapService.directions('Toronto', 'Montreal')
/usr/local/lib/python2.7/dist-packages/urllib3/util/ssl_.py:100: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/googlemaps/directions.py", line 150, in directions
return client._get("/maps/api/directions/json", params)["routes"]
File "/usr/local/lib/python2.7/dist-packages/googlemaps/client.py", line 222, in _get
result = self._get_body(resp)
File "/usr/local/lib/python2.7/dist-packages/googlemaps/client.py", line 245, in _get_body
body["error_message"])
googlemaps.exceptions.ApiError: REQUEST_DENIED (This API project is not authorized to use this API. Please ensure that this API is activated in the APIs Console: Learn more: https://code.google.com/apis/console)