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

Plotly python 'save_as' function returns 'The response from plotly could not be translated.' error

Hi everyone,
I just started using plotly for data visualization in Python 3.

Within one script I am generating an offline .html file, then I am logging into my account to save the file as a static .png file like this:

'#'doing offline .html file generation
plotly.plotly.sign_in(username=‘username’, api_key=‘password’)
layout = go.Layout(title=‘title’, width=800, height=600)
fig = go.Figure(data=data, layout=layout)
plotly.plotly.image.save_as(fig, filename=‘test.png’)

This raises the following error:

Traceback (most recent call last):
File “C:\Users_\Anaconda3\lib\site-packages\plotly\plotly\”, line 703, in get
return_data = json.loads(res.content)
File “C:\Users_\Anaconda3\lib\”, line 312, in loads
TypeError: the JSON object must be str, not ‘bytes’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “”, line 57, in
plotly.plotly.image.save_as(fig, filename=‘test.png’)
File “C:\Users_\Anaconda3\lib\site-packages\plotly\plotly\”, line 787, in save_as
img = cls.get(figure_or_data, format, width, height, scale)
File “C:\Users_\Anaconda3\lib\site-packages\plotly\plotly\”, line 707, in get
raise exceptions.PlotlyError("The response "
plotly.exceptions.PlotlyError: The response from plotly could not be translated.

Any suggestions what I am doing wrong?