Skip to content Skip to sidebar Skip to footer

Python Plotly: AttributeError: 'PlotlyJSONEncoder' Object Has No Attribute 'encoding'

I am getting an error when trying to plot the basic chart on the Plotly Tutorial: https://plot.ly/python/getting-started/. Full traceback here: Traceback (most recent call last):

Solution 1:

Full disclosure, I work for Plotly.

TL;DR

Looks like a recent change isn't fully compatible with your Python version.

pip install -I 'plotly==1.6.10'

That's just before the change that seems to be affecting you.

Explanation

The Plotly python module recently just updated our custom JSONEncoder subclass to convert float('NaN'), float('Inf'), and float('-Inf') to null instead to to the extended JSON values nan, Infinity, and -Infinity.

https://docs.python.org/2/library/json.html#infinite-and-nan-number-values

To do this we overrode iterencode from the default JSONEncoder. Something may have changed between the version of this we develop on and your version.

Permanent Fix

We'll try and recreate the error and come up with a fix shortly, thanks for posting about it!

(edit, there should have been two = signs in the pip command)


Post a Comment for "Python Plotly: AttributeError: 'PlotlyJSONEncoder' Object Has No Attribute 'encoding'"