Black Lives Matter. Please consider donating to Black Girls Code today.

Unable to publish plotly express plot to Chart Studio

I can publish the following example plot to Chart Stuido:

import chart_studio.plotly as py
import plotly.graph_objects as go
trace0 = go.Scatter(
    x=[1, 2, 3, 4],
    y=[10, 15, 13, 17]
)
trace1 = go.Scatter(
    x=[1, 2, 3, 4],
    y=[16, 5, 11, 9]
)
data = [trace0, trace1]
py.plot(data, filename = 'test2', auto_open=True)

However, it’s not working for plot created using Plotly Express:

import plotly.express as px
import chart_studio.plotly as py
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length")
data = [fig]
py.plot(data, filename = 'test3', auto_open=True)

… I got the following error message:

ValueError                                Traceback (most recent call last)
 in 
      7 
      8 data = [fig]
----> 9 py.plot(data, filename = 'test3', auto_open=True)

May I ask why?