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

Changing html_directory for iframe renderer

I am having difficulty changing the html_directory for the iframe renderer when using jupyterlab.

My project directory structure is as follows:

project/ # working directory
project/notebooks/. # notebook here
project/src/

NOTE - the working directory has to be set as the top-level project directory, NOT the location of the notebook.

I’ve set the renderer as follows:

import plotly.io as pio
iframe_renderer = pio.renderers['iframe_connected']
iframe_renderer.html_directory='notebooks/iframe_figures'
pio.renderers.default = "iframe_connected"

This ends up with the following directory structure:

project/ # working directory
project/notebooks/ # notebook here
project/notebooks/iframe_figures/
project/src/

However, when calling fig.show(), I end up with 404 Not Found.

Also, if I just use the renderer as is, without changing the html_directory, I end up with the following directory structure:

project/ # working directory
project/notebooks/ # notebook here
project/iframe_figures/
project/src/

and I still have a 404 Not found error.

It seems that the HTML files are getting written to the correct directory. But fig.show() is only able to view the generated files if they exist in a directory iframe_figures/ which exists in the same directory as the notebook…