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

RuntimeError: maximum recursion depth exceeded

I began hitting this error after deleting a graph online and trying to replot locally. Both py.iplot and py.plot return same error.
Traceback as follows

File “/home/ktavabi/Projects/”, line 241, in plot
res = _send_to_plotly(figure, **plot_options)
File “/home/ktavabi/Projects/”, line 1401, in _send_to_plotly
File “/home/ktavabi/anaconda2/lib/python2.7/json/”, line 251, in dumps
sort_keys=sort_keys, **kw).encode(obj)
File “/home/ktavabi/Projects/”, line 145, in encode
encoded_o = super(PlotlyJSONEncoder, self).encode(o)
File “/home/ktavabi/anaconda2/lib/python2.7/json/”, line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File “/home/ktavabi/anaconda2/lib/python2.7/json/”, line 270, in iterencode
return _iterencode(o, 0)
File “/home/ktavabi/Projects/”, line 208, in default
return encoding_method(obj)
File “/home/ktavabi/Projects/”, line 217, in encode_as_plotly
return obj.to_plotly_json()

Hey @kambysese

It looks like some error associated with JSON-ifying the figure. Could you paste the entire code snippet or a smaller code block that reproduces the issue?

I had this exact error, and was confused for hours because I had reused code that worked in a very similar situation. My data was an array of numpy.float128 objects. The issue was fixed by casting it to python float before adding it to my plot.

I haven’t seen anywhere in the Plotly documentation that says certain numpy datatypes aren’t supported for position data, but regardless, Plotly should support numpy datatypes like float128 for convenience. However, for anyone whose code throws a similar error, make sure that the data you’re trying to plot is of a type provided by the Python standard library.