✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚾️ It's finally Baseball season! Root for the home team... & Register for our Sports Analytics Webinar!

Py.image.save_as unknown error

I took this code from the site (mostly):

import plotly.plotly as py
from plotly.graph_objs import Bar, Scatter, Figure, Layout

trace = Bar(x=[1,2,3],y=[4,5,6])
data = [trace]
layout = Layout(title=‘My Plot’)
fig = Figure(data=data,layout=layout)

Save the figure as a png image:

py.image.save_as(fig, ‘my_plot.png’)

and when I run it I get the following error:

Traceback (most recent call last):
File “chart.py”, line 22, in
py.image.save_as(fig, ‘/home/ubuntu/coinbase/my_plot.png’)
File “/usr/local/lib/python2.7/dist-packages/plotly/plotly/plotly.py”, line 787, in save_as
img = cls.get(figure_or_data, format, width, height, scale)
File “/usr/local/lib/python2.7/dist-packages/plotly/plotly/plotly.py”, line 710, in get
raise exceptions.PlotlyError(return_data[‘error’])
KeyError: ‘error’

Any ideas?

I have the same error and have added a more detailed description of the problem. (http://community.plotly.com/t/missing-function-for-offline-plots-in-python)

But I also don’t have a clue how to fix this…