Search code examples
pythonvisual-studio-codejupyter-notebookplotlynbconvert

using plotly in offline mode in jupyter notebook (using nbcovert --execute) opens IDE (vscode)


I am kinda confused why this is happening if running a jupyter notebook (using nbconvert --execute) with the following code:

for key in dict:
   data = [go.Bar (x = dict[key].values(),
                   y = dict[key].keys(),
                   orientation = 'h')]

   layout = go.Layout(title = key, showlegend = False)
   fig = go.Figure(data = data, layout = layout)
   plotly.offline.plot(fig, filename= plots_path + key + '_plotly.html')

always leads to starting vs-code. Does anyone experienced that issue before ? How can I suppress it because I do the plotting in a loop and it is quite annoying to close more than 10 vs-code windows after each run.

Apparently it has to do something with the writing to html if I comment the last line out no vs-code windows are popping up.


Solution

  • Try this: plotly.offline.plot(fig, filename= plots_path + key + '_plotly.html', auto_open=False)

    Default behavior is it will try to find a program to immediately open the html file.