英文:
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
英文:
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 an link where I'll use ctrl + click and it should open a page showing Hello world:
This is the supposed output
答案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__ == '__main__':
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 .
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论