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 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),
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);

, mapbox_center = {“lat”: map_meanY, “lon”: map_meanX}
, mapbox_zoom= 11
#, clickmode=‘event+select’

scatter =[0]

f2.layout.hovermode = ‘closest’

out = Output()
def click_callback(trace, points, selector):
inds = points.point_inds

#the click event

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