Unable to save static file on windows (works on mac)

Hello,

I’m having issues with a script I know works on mac as expected but the same script on windows causes my script to hang and does not generate output using the .write_image() function. I have tried uninstalling/reinstalling the plotly library on the windows machine and can see plotly is working as expected with the .show() function. Below is one of my functions I have been using plotly with and am trying to get working again before replicating any changes in other plotting functions.

import plotly.graph_objects as go

def returns(dataframe, symbol):
    profit = go.Figure(data = [go.Scatter(name='profit', x = dataframe.index, y = dataframe[('profit')], line = dict(color="#ef553b", width=2) )])
    profit.update_layout(xaxis_rangeslider_visible = False, title = '{} Profit'.format(symbol))
    profit.update_xaxes(title_text = 'Date')
    profit.show()
    profit.write_image("Plots/{}_Profit.png".format(symbol), width=1440, height=700)

To elaborate on the above, the plot uses date (dataframe.index) on the x-axis and a profit/value series (dataframe[(‘profit’)]) on the y-axis. The output of profit.show() is something like the below varying with input parameters. I don’t want to have an endless number of tabs opening when using this in a loop hence I am trying to save the files for more controlled and orderly access :slightly_smiling_face: I do have a Plots folder to save the file into. It has been working well on mac but it looks like there may be a compatibility issue moving to windows with powershell.

Has anyone else had a similar issue to this?

Thank you in advance for any help you can offer,