'Geoplotlib AttributeError: 'bytes' object has no attribute 'encode'

I am working with geoplotlib and trying to show a map with known latitudes and longitudes values as float. But i keep getting the error as seen below.

min_lat = 51
max_lat = 58
min_lon = 0
max_lon = -6

latitudes  = [entry  for entry in latitudes]
longitudes = [entry for entry in longitude]

bbox = BoundingBox(north=max_lat, south=min_lat, west=min_lon, east=max_lon)
geoplotlib.set_bbox(bbox)

geo_data_for_plotting = {"lat": latitudes,
                         "lon": longitudes}

geoplotlib.kde(geo_data_for_plotting, bw=[0,0.125])
geoplotlib.inline()

error is

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
C:\Users\OLUMOR~1\AppData\Local\Temp/ipykernel_1288/1765196798.py in <module>
     15 
     16 geoplotlib.kde(geo_data_for_plotting, bw=[0,0.125])
---> 17 geoplotlib.inline()

~\anaconda3\envs\itops\lib\site-packages\geoplotlib\__init__.py in inline(width)
     69     if os.path.isfile(fname + '.png'):
     70         with open(fname + '.png', 'rb') as fin:
---> 71             base64 = urllib.parse.quote(fin.read().encode("base64"))
     72 
     73         image_html = "<img style='width: %dpx; margin: 0px; float: left; border: 1px solid black;' src='data:image/png;base64,%s' />" % (width, base64)

AttributeError: 'bytes' object has no attribute 'encode'


Solution 1:[1]

After you make the dict, add the following line to transform it into a DataAccessObject:

geo_data_for_plotting = geoplotlib.utils.DataAccessObject(geo_data_for_plotting)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BeRT2me