-1

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):

File "testing_plotly.py", line 13, in unique_url = py.plot(data, filename = 'basic-line')

File "C:\Python34\lib\site-packages\plotly\plotly\plotly.py", line 186, in plot res = _send_to_plotly(figure, **plot_options)

File "C:\Python34\lib\site-packages\plotly\plotly\plotly.py", line 1229, in _se cls=utils.PlotlyJSONEncoder)

File "C:\Python34\lib\json__init__.py", line 237, in dumps **kw).encode(obj)

File "C:\Python34\lib\json\encoder.py", line 192, in encode chunks = self.iterencode(o, _one_shot=True)

File "C:\Python34\lib\site-packages\plotly\utils.py", line 151, in iterencode if self.encoding != 'utf-8': AttributeError: 'PlotlyJSONEncoder' object has no attribute 'encoding'

Thanks!

sqluser
  • 5,502
  • 7
  • 36
  • 50

1 Answers1

3

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)

theengineear
  • 857
  • 6
  • 6