Hey everybody,
I tried to get a image of a bar chart using only plotly offline without anyy results. After ours of trying I’m quite sure the I found the reason why this isn’t working (just to get an image “by code” isn’t possible, a normal offline plot of the same data is possible).
Executing the sample from https://plot.ly/python/static-image-export/ I first got this error message:
Traceback (most recent call last):
File “/usr/local/lib/python3.4/dist-packages/plotly/plotly/plotly.py”, line 703, in get
return_data = json.loads(res.content)
File “/usr/lib/python3.4/json/init.py”, line 312, in loads
s.class.name))
TypeError: the JSON object must be str, not ‘bytes’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “barcharttest2.py”, line 42, in
py.image.save_as(fig, ‘/home/pi/plotlytest/test.png’)
File “/usr/local/lib/python3.4/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/python3.4/dist-packages/plotly/plotly/plotly.py”, line 707, in get
raise exceptions.PlotlyError("The response "
plotly.exceptions.PlotlyError: The response from plotly could not be translated.
After Searching the Internet and especially github I copied the relevant code out of the libraries and tried to save an image manually. And so I got this error displayed:
Traceback (most recent call last):
File “barcharttest2.py”, line 27, in
img = cls.get(fig, format, width, height, scale)
AttributeError: type object ‘PlotlyJSONEncoder’ has no attribute ‘get’
I checked the code for the missing get but can’t find it.
Could someone please help me to find a solution for my problem or in case this is really a bug in plotly offline (advise to) fix this?
Greetings
Tim