Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot import name GoogleMaps

I followed the instruction

pip install GoogleMaps

to install google maps. but when I tried to import the GoogleMaps class, it failed although googlemaps is installed.

Python 2.7.6 (default, Mar 22 2014, 22:59:38)  [GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import googlemaps 
>>>
>>> from googlemaps import GoogleMaps 
Traceback (most recent call last):   
File "<stdin>", line 1, in <module> 
ImportError: cannot import name GoogleMaps

Does anyone know why GoogleMaps cannot be imported although googlemaps is installed?

like image 263
likekeustc Avatar asked Dec 04 '14 11:12

likekeustc


2 Answers

Maybe the documentation is a little bit outdated: use Client instead of GoogleMaps

>>> from googlemaps import Client
>>> dir(Client)
['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_generate_auth_url', '_get', 'directions', 'distance_matrix', 'elevation', 'elevation_along_path', 'geocode', 'reverse_geocode', 'timezone']
>>> help(Client)
like image 84
Michele d'Amico Avatar answered Oct 27 '22 17:10

Michele d'Amico


I think there is no class defined named GoogleMaps in googlemaps module.

if you try help(googlemaps) in python interpreter then you can able to see all the classes.

I hope this helps you.

like image 38
Sagar Avatar answered Oct 27 '22 19:10

Sagar