pbugnion / gmaps

Google maps for Jupyter notebooks
https://jupyter-gmaps.readthedocs.io/en/stable/
Other
760 stars 146 forks source link

module 'gmaps' has no attribute 'symbol' #363

Open WillMcCall opened 1 year ago

WillMcCall commented 1 year ago

I was able to run this same code using a heatmap layer instead of using a symbol but for some reason when I try to run it using a symbol it returns "module 'gmaps' has no attribute 'symbol'". I'm running this on a Jupyter Notebook and I have the latest version of gmaps which I installed using conda. I'm not sure what I've done wrong exactly (sorry if this is silly, I'm trying to learn coding for my new job).

 import gmaps

  gmaps.configure(api_key="***")

  locations = [(42.5, 88.3), (40.3, 90.2)]

  fig = gmaps.figure()
  marker_layer = gmaps.symbol(
      locations, fill_color="purple", stroke_color="purple",scale=5
  )
  fig.add_layer(marker_layer)
  fig
CrepeGoat commented 1 year ago

Hey @WillMcCall! I'm not a maintainer or anything, but I happened on this and think I can maybe help.

your immediate problem

Firstly, it looks like your example code is similar to the examples in this part of the tutorial. There it looks like the function name you want is symbol_layer, instead of symbol.

other problems

However, when I tried to run your code with ^my fix, I got another error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-09538d5bc6cd> in <cell line: 8>()
      6 
      7 fig = gmaps.figure()
----> 8 marker_layer = gmaps.symbol_layer(
      9     locations, fill_color="purple", stroke_color="purple",scale=5
     10 )

2 frames

[...]

/usr/local/lib/python3.10/dist-packages/gmaps/options.py in is_atomic(elem)
     38     return (
     39         isinstance(elem, string_types) or
---> 40         not isinstance(elem, collections.Iterable)
     41     )
     42 

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

This looks like gmaps is misusing Python's builtin collections module. Specifically, Iterable used to be in collections but was moved to collections.abc way back in Python version ~3.3?, which has been in EOF for over a decade.

Looking further into it, the setup.py file here seems to suggest that this package supports Python version up to 3.6.

On top of that, this repo seems to not have seen any changes since 2019.

tl;dr: this gmaps package may be abandoned and out-of-date. If you want to use it, you unfortunately may have to do some maintenance yourself.

my recommendations

In general, I'd recommend asking these kinds of usage questions on Stack Overflow, instead of as an issue in the repo. You have a better chance of getting a decent answer (there are always SO users, but maintainers may disappear), and worst-case they'll tell you to message the package maintainers anyway.

Good luck with your efforts!