找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 6141|回复: 1

[求助] TypeError: Object of type 'function' is not JSON serializable

1

主题

2

帖子

2

积分

贫民

积分
2
白马出凉州 发表于 2021-3-15 22:13:43 | 显示全部楼层 |阅读模式
1威望
函数类型不是JSON 序列化需求的类型,这个有大神可以帮忙看看吗?python3用到bokeh制表的library

def selectAllCallback(epnoPlotSource=epnoPlot, toPlotSource=TOPlot, smtToPlotSource=smtTOPlot,
    phasePlotSource=phasePlot, smtPhasePlotSource=smtPhasePlot, ampRatioPlotSource=ampRatioPlot,
    ampPlotSource=ampPlot, peakPlotSource=peakPlot, absoluteAmpPlotSource=absoluteAmpPlot):

rxtxSelect.js_on_change('value', CustomJS(args=dict(source=commonCallback),code=""))
lnCellSelect.js_on_change('value', CustomJS(args=dict(source=commonCallback),code=""))
selectAllButton.js_on_click(CustomJS(args=dict(source=selectAllCallback),code=""))
clearAllButton.js_on_click(CustomJS(args=dict(source=clearAllCallback),code=""))

c = column(epnoPlot,TOPlot,smtTOPlot,phasePlot,smtPhasePlot,ampRatioPlot,ampPlot,peakPlot,absoluteAmpPlot)
l = layout([[rxtxSelect, lnCellSelect], [selectAllButton, clearAllButton],c])
save(l)


Traceback (most recent call last):
  File "update.py", line 709, in <module>
    output = calibrationLog.findAndAnalyzer()
  File "update.py", line 206, in findAndAnalyzer
    drawChart(self.checkCaliResult.chartValDict)
  File "update.py", line 673, in drawChart
    save(l)
  File "/opt/ute/python3/lib/python3.6/site-packages/bokeh/io/saving.py", line 86, in save
    _save_helper(obj, filename, resources, title, template, theme)
  File "/opt/ute/python3/lib/python3.6/site-packages/bokeh/io/saving.py", line 148, in _save_helper
    html = file_html(obj, resources, title=title, template=template, theme=theme)
  File "/opt/ute/python3/lib/python3.6/site-packages/bokeh/embed/standalone.py", line 304, in file_html
    (docs_json, render_items) = standalone_docs_json_and_render_items(models_seq, suppress_callback_warning=suppress_callback_warning)
  File "/opt/ute/python3/lib/python3.6/site-packages/bokeh/embed/util.py", line 294, in standalone_docs_json_and_render_items
    docs_json[docid] = doc.to_json()
  File "/opt/ute/python3/lib/python3.6/site-packages/bokeh/document/document.py", line 902, in to_json
    doc_json = self.to_json_string()
  File "/opt/ute/python3/lib/python3.6/site-packages/bokeh/document/document.py", line 959, in to_json_string
    return serialize_json(json, indent=indent)
  File "/opt/ute/python3/lib/python3.6/site-packages/bokeh/core/json_encoder.py", line 166, in serialize_json
    return json.dumps(obj, cls=BokehJSONEncoder, allow_nan=False, indent=indent, separators=separators, sort_keys=True, **kwargs)
  File "/opt/ute/python3/lib/python3.6/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/opt/ute/python3/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/opt/ute/python3/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/opt/ute/python3/lib/python3.6/site-packages/bokeh/core/json_encoder.py", line 261, in default
    return self.transform_python_types(obj)
  File "/opt/ute/python3/lib/python3.6/site-packages/bokeh/core/json_encoder.py", line 228, in transform_python_types
    return super().default(obj)
  File "/opt/ute/python3/lib/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'function' is not JSON serializable

回复

使用道具 举报

1

主题

2

帖子

2

积分

贫民

积分
2
白马出凉州  楼主| 发表于 2021-3-15 22:17:22 | 显示全部楼层
代码没有贴完全,有兴趣的大神帮忙看下,我可以发你代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表