[Python] plotly: TypeError: cannot convert dictionary update sequence element #0 to a sequence

Discussão em 'Python' iniciado por Stack, Maio 19, 2025.

  1. Stack

    Stack Membro Participativo

    I have a problem with the project I'm currently working on, so I'm leaving a question.
    The current contents are drawn in table format by sensor. But a few days ago, when I was working on something, I didn't know how to fix it, so I asked for help.

    import plotly.plotly as py
    import plotly.figure_factory as ff
    from bluepy import sensortag
    import sys
    import time
    import datetime
    import numpy as np

    py.sign_in("smrlswja9963","94b4enXKYqyOu4iuPDGG")

    time.sleep(1.0)

    tag = sensortag.SensorTag('24:71:89:CC:53:00')
    tag.IRtemperature.enable()
    tag.humidity.enable()

    stream1=py.Stream('liz9v2c0or')
    stream1.open()

    i=0
    while True:
    now = datetime.datetime.now()
    dateTime = now.strftime("%Y-%m-%d %H:%M:%S")

    A = tag.IRtemperature.read()
    B = tag.humidity.read()
    tempt=A[0]
    humty=B[0]

    stream1.write({dateTime,tempt,humty})

    i+=1

    tag.waitForNotifications(3.0)

    table = go.Table(
    header=dict(values=["dateTime","tempt","humty"]),
    cells=dict(values=[[dateTime],[tempt],[humty]]),
    stream = dict(token='liz9v2c0or',))

    data=[table]
    py.iplot(table, filename="latex table")


    After executing the following code, the following error occurred.

    Traceback (most recent call last):
    File "/home/pi/do it.py", line 27, in <module>
    stream1.write({dateTime,tempt,humty})
    File "/usr/local/lib/python2.7/dist-packages/plotly/plotly/plotly.py", line 632, in write
    stream_object.update(trace)
    TypeError: cannot convert dictionary update sequence element #0 to a sequence


    In this case, the code that I draw the graph using plolty does not have a problem when receiving data from stream, but when I draw table plot.

    How can I graph here? I'm really curious. Please let me know.

    Continue reading...

Compartilhe esta Página