TypeError: ‘Div’ object is not callable

huangapple go评论74阅读模式
英文:

TypeError: 'Div' object is not callable

问题

I'm working with plotly to visualize data this is the code I have so far:

input:

from dash import Dash, html

#initialize app
app = Dash(__name__)

# App layout
app.layout = html.Div([
    html.Div(children='Hello World')
])

#run app
if __name__ == '__main__':
    app.layout(debug=True)

output:

Traceback (most recent call last):
  File "C:\Users\<private>\<private>\<private>\Documents\pythonVisualize\app.py", line 14, in <module>
    app.layout(debug=True)
TypeError: 'Div' object is not callable

Why am I getting this error? While this is a copy and paste from Plotly How can I fix this?

After running this using: python .\app.py, I'm supposed to get a link where I'll use ctrl + click, and it should open a page showing Hello world:

This is the supposed output

TypeError: ‘Div’ object is not callable

英文:

I'm working with plotly to visualize data this is the code I have so far:

input:

from dash import Dash, html

#initialize app
app = Dash(__name__)

# App layout
app.layout = html.Div([
    html.Div(children=&#39;Hello World&#39;)
])


#run app
if __name__ == &#39;__main__&#39;:
    app.layout(debug=True)

output:

Traceback (most recent call last):
  File &quot;C:\Users\&lt;private&gt;\&lt;private&gt;\&lt;private&gt;\Documents\pythonVisualize\app.py&quot;, line 14, in &lt;module&gt;
    app.layout(debug=True)
TypeError: &#39;Div&#39; object is not callable

Why am I getting this error? While this is a copy and paste from Plotly How can I fix this?

After running this using: python .\app.py, I'm supposed to get an link where I'll use ctrl + click and it should open a page showing Hello world:

This is the supposed output

TypeError: ‘Div’ object is not callable

答案1

得分: 0

尝试在你的主程序中添加 app.run()。这是来自文档 (https://dash.plotly.com/tutorial) 的示例代码:

if __name__ == '__main__':
    app.run(debug=True)

你可以在这个帖子中找到更多关于如何运行它的解释和方法:https://stackoverflow.com/q/73719291/13339621。

英文:

Try adding app.run() in your main. This is from the documentation (https://dash.plotly.com/tutorial) .

if __name__ == &#39;__main__&#39;:
    app.run(debug=True)

You'll find further explanations and ways to run it as explained in the post: https://stackoverflow.com/q/73719291/13339621 .

huangapple
  • 本文由 发表于 2023年6月29日 15:11:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76578782.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定