[Python] converting jupyter notebook (.ipynb) with to HTML using nbconvert - plotly figures...

Discussão em 'Python' iniciado por Stack, Maio 14, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following code in a notebook cell:

    import plotly.express as px

    fig = px.scatter(x=[1,2,3], y=[1,2,3])
    fig.show()


    and I'm trying to convert it to HTML, like this:

    jupyter nbconvert --to html --execute try.ipynb


    The HTML I get does not display the plotly figure. It does display markdown, code, and figures generated using other packages.
    Based on previous answers, I've tried adding:

    import plotly.io as pio
    pio.renderers.default = "notebook_connected"


    and also running:

    jupyter nbconvert --to html --execute --template classic --embed-images try.ipynb


    but nothing worked.
    Interestingly, if I set the default renderer to svg:

    pio.renderers.default = "svg"


    it shows in the HTML. But I want my figures to be interactive.

    Any idea what might be going wrong?
    Please note that the code above is just a minimal example. In practice I have multiple figures, tables, and markdown that I wish to include in a HTML report.

    Continue reading...

Compartilhe esta Página