Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'collections' has no attribute 'Iterable' #354

Open
rogeriobiondi opened this issue Apr 22, 2022 · 1 comment
Open

Comments

@rogeriobiondi
Copy link

rogeriobiondi commented Apr 22, 2022

Hello,

I'm trying to run the example from the documentation:

import gmaps
gmaps.configure(api_key='KEY...')
nuclear_power_plants = [
{'name': 'Atucha', 'location': (-34.0, -59.167), 'active_reactors': 1},
{'name': 'Embalse', 'location': (-32.2333, -64.4333), 'active_reactors': 1},
{'name': 'Armenia', 'location': (40.167, 44.133), 'active_reactors': 1},
{'name': 'Br', 'location': (51.217, 5.083), 'active_reactors': 1},
{'name': 'Doel', 'location': (51.333, 4.25), 'active_reactors': 4},
{'name': 'Tihange', 'location': (50.517, 5.283), 'active_reactors': 3}
]
plant_locations = [plant['location'] for plant in nuclear_power_plants]
info_box_template = "<dl><dt>Name</dt><dd>{name}</dd><dt>Number reactors</dt><dd>{active_reactors}</dd></dl>"
plant_info = [info_box_template.format(**plant) for plant in nuclear_power_plants]
marker_layer = gmaps.marker_layer(plant_locations, info_box_content=plant_info)
fig = gmaps.figure()
fig.add_layer(marker_layer)

But receiving the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [11], in <cell line: 14>()
     12 info_box_template = "<dl><dt>Name</dt><dd>{name}</dd><dt>Number reactors</dt><dd>{active_reactors}</dd></dl>"
     13 plant_info = [info_box_template.format(**plant) for plant in nuclear_power_plants]
---> 14 marker_layer = gmaps.marker_layer(plant_locations, info_box_content=plant_info)

File ~/.pyenv/versions/3.10.4/envs/teste/lib/python3.10/site-packages/gmaps/marker.py:553, in marker_layer(locations, hover_text, label, info_box_content, display_info_box)
    485 @doc_subst(_doc_snippets)
    486 def marker_layer(
    487         locations, hover_text='', label='',
    488         info_box_content=None, display_info_box=None):
    489     """
    490     Marker layer
    491 
   (...)
    551         A :class:`gmaps.Markers` instance.
    552     """
--> 553     marker_options = _marker_layer_options(
    554         locations, hover_text, label, info_box_content, display_info_box)
    555     markers = [Marker(**option) for option in marker_options]
    556     return Markers(markers=markers)

File ~/.pyenv/versions/3.10.4/envs/teste/lib/python3.10/site-packages/gmaps/marker.py:311, in _marker_layer_options(locations, hover_text, label, info_box_content, display_info_box)
    309 if is_atomic(label):
    310     label = [label] * number_markers
--> 311 if is_atomic(info_box_content):
    312     info_box_content = [info_box_content] * number_markers
    314 marker_options = {
    315     'location': locations_to_list(locations),
    316     'hover_text': hover_text,
    317     'label': label
    318 }

File ~/.pyenv/versions/3.10.4/envs/teste/lib/python3.10/site-packages/gmaps/options.py:40, in is_atomic(elem)
     34 def is_atomic(elem):
     35     """
     36     True if an element is a single atom and false if it's a collection
     37     """
     38     return (
     39         isinstance(elem, string_types) or
---> 40         not isinstance(elem, collections.Iterable)
     41     )

AttributeError: module 'collections' has no attribute 'Iterable'

I'm using the latest gmaps library version 0.9.0 and Python 3.10.4.

Thanks

@AlexRossiATF
Copy link

AlexRossiATF commented Apr 28, 2022

Hi @rogeriobiondi, collections.Iterable has been deprecated and now it is in collections.abc.Iterable.
Either you substitute collections.Iterable in the source code of the library or you should use a less recent version of python, I would say <= 3.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants