I am trying to convert my (working, functional) app into a multi-page version, following Adam’s video published in December. But I receive this curious error message.
I can find online references to similar messages, but not to this one specifically, and none that seem to offer clues to a solution. I don’t recall making any changes to the templates, and I think I installed the relevant libraries.
Here is the error message again:
AttributeError: module ‘dash’ has no attribute ‘register’.
There are only three pages in my multi-page app to start, and I thought I had them properly “registered” as shown below. Can anyone shed some light on this issue?
Thank you for your feedback.
1. app.py applicable code, or at least I think so:
Well, that’s what happens when you stop drinking coffee!
Thanks so much. It is up and running - but for other, yet defined reasons - it is not working as it should. It looks great, but it suddenly does not accept and process recipes, which it does well as a standalone app.
Have just had the same issue, although no typo. my workaround was to add the code below into each app page’s code to find the register_page function. Not sure why mine didn’t work as planned, as dash and dash-labs are installed, perhaps I have a PATH issue but not sure
from dash_labs.plugins.pages import register_page
register_page(__name__, path='/')
You don’t have a PATH issue or a typo. dash.register_page was renamed to dash_labs.plugins.register_page in dash-labs version 1.1.0.
There will be an announcement coming soon, but the pages feature is now available in dash 2.5.
It was necessary to change the name of register_page because there is a conflict if you use dash-labs version < 1.1.0 and dash >= 2.5.0.
Traceback (most recent call last):
File “C:\MuliPageAppTest\App\appTest.py”, line 27, in
app = dash.Dash(
File “C:\Users\dash_server\AppData\Local\Programs\Python\Python39-32\lib\site-packages\dash\dash.py”, line 423, in init
plugin.plug(self)
File “C:\Users\dash_server\AppData\Local\Programs\Python\Python39-32\lib\site-packages\dash_labs\plugins\pages.py”, line 327, in plug
_import_layouts_from_pages(pages_folder)
File “C:\Users\dash_server\AppData\Local\Programs\Python\Python39-32\lib\site-packages\dash_labs\plugins\pages.py”, line 301, in import_layouts_from_pages
page_module = importlib.import_module(f"pages.{page_filename}")
File "C:\Users\dash_server\AppData\Local\Programs\Python\Python39-32\lib\importlib_init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1030, in _gcd_import
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “”, line 850, in exec_module
File “”, line 228, in _call_with_frames_removed
File “C:\MuliPageAppTest\App\pages\AkustikTest.py”, line 2, in
dash.register_page(name)
AttributeError: module ‘dash’ has no attribute ‘register_page’
I’m having similar issues and can’t figure it out. It looks like I’m following the examples.
I upgraded to dash 2.5.1 yesterday, I don’t use dash_labs.
My file structure is
Index.py
app.py
layout.py (serves the layout to app.py over a function call)
pages/page1.py
I’m getting the following error in the pages/page1.py file
AttributeError: module ‘dash.dash’ has no attribute ‘register_page’
originating from dash.py line 2193 in _import_layouts_from_pages spec.loader.exec_module(page_module)
Ok so I may have figured it out, I also figured after spending half a day with no success the moment I posted I’d figure something out.
The problem was something with my other import statements which may have overwrote the initial or changed it somehow. I moved the dash.register_page directly under the import dash and it started working.
Now I’m not able to get the nav bar to show. I grabbed the following from the template and all I see is the color and the title Multi page app demo but nothing else.
nav2 = dbc.NavbarSimple(
dbc.Nav(
[
dbc.NavLink(page[“name”], href=page[“path”])
for page in dash.page_registry.values()
if page.get(“top_nav”)
],
),
brand=“Multi Page App Demo”,
color=“primary”,
dark=True,
className=“mb-2”,
)