Invalid property path 'mapbox._derived' for layout

Hi, I am working on a Jupyter Notebook and trying to implement a click event on a scattermapbox plot, and this seems to work when I change mode=‘markers+text’ to mode=‘markers’, but when I do this, I get a ValueError:
invalid property path ‘mapbox._derived’ for layout

It must be something small, as it works for all the other types, and I would very much appreciate it if someone could have a look at the code below:

Import libraries

import pandas as pd
import numpy as np
import plotly.express as px
import plotly.graph_objects as go
import json
import ipywidgets as widgets
from ipywidgets import Output, VBox
from plotly.graph_objs import FigureWidget
from plotly.callbacks import Points, InputDeviceState

data2 = go.Scattermapbox(lat=list(heat_df.ycoord),
lon=list(heat_df.xcoord),
mode=‘markers’,
marker=dict(size=20, color=‘green’),
)

layout = dict(margin=dict(l=0, t=0, r=0, b=0, pad=0),

f2 = go.FigureWidget(data=[data2], layout=layout);

f2.update_layout(mapbox_style=“stamen-terrain”
, mapbox_center = {“lat”: map_meanY, “lon”: map_meanX}
, mapbox_zoom= 11
#, clickmode=‘event+select’
);

scatter = f2.data[0]

f2.layout.hovermode = ‘closest’

out = Output()
@out.capture(clear_output=True)
def click_callback(trace, points, selector):
inds = points.point_inds
print(inds)

#the click event
scatter.on_click(click_callback)

widgets.VBox([widgets.HBox([reset, export]), widgets.VBox([f2, out])])