如何在dash应用程序中启动app.py时使用__init__循环错误



这是我的结构

app/
assets/
data/
__init__.py
app.py
figures.py
template.py
requirements.txt

myinit.py:

import dash
import dash_auth
USERNAME_PASSWORD_PAIRS = [['xx','xx']]
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from app.languages import app_en, app_fr
app = dash.Dash(__name__, meta_tags=[
{'name': 'viewport', 'content': 'width=device-width'},
{'name': 'description', 'content': 'Well-being survey dashboard / Tableau de bord Enquete Bien Etre'},
])
app.title = 'Well-being survey dashboard'
app.config.suppress_callback_exceptions = True
auth = dash_auth.BasicAuth(app,USERNAME_PASSWORD_PAIRS)
# WSGI entry point
server = app.server

app.layout = html.Div([
dcc.Location(id='url', refresh=False),
html.Div(id='page-content')
])

@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/':
return app_fr.layout
elif pathname == '/fr':
return app_fr.layout
elif pathname == '/en':
return app_en.layout
else:
return '404: Page Not Found'

应用程序

from __init__ import app
if __name__ == '__main__':
app.run_server(debug=False)

template.py:我必须导入数字,唯一的方法是:将app.figures导入为数字对我来说,这很奇怪,因为我应该这么做。数字就是数字。。。

我的错误是在启动app.py:时

init导入应用程序ImportError:无法从部分初始化的模块">init"导入名称"app"(很可能是由于循环导入((/Users/philippehaumesser/PycharmProjects/bienetre/app/init.py(

多亏了coral vanda,我只在所有子文件夹中添加了init.py文件,它就可以工作了。感谢

最新更新