Can someone please explain this error message? AttributeError: module 'dash' has no attribute 'register'

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:

app = dash.Dash(
    __name__, plugins=[dl.plugins.pages], external_stylesheets=[dbc.themes.SUPERHERO])

2. submit_recipe.py probable applicable code:

dash.register(page(__name__, path='/'))

external_stylesheets=[dbc.themes.SUPERHERO]

app = dash.Dash(external_stylesheets=external_stylesheets)

3. barchart.py probable applicable code:

dash.register_page(__name__)

external_stylesheets = [dbc.themes.SUPERHERO]

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

Hi @robertpfaff,

You have a typo in point 2:

dash.register_page(__name__, path='/')
1 Like

Well, that’s what happens when you stop drinking coffee! :smile:

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.

I guess I have my work cut out for me today.

Thanks again and take care,

Robert

1 Like

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='/')

hi @brendon

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. :confetti_ball:
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.

1 Like

I have a simulat issue with my multi page app

dash version: 2.0.0
dash_bootstrap_components version: 1.1.0

Error on my 32 bit Windows:

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’

Hi @Mae

I recommend upgrading to dash 2.5.1. You can find instructions on how to convert a dash-labs multi-page app to dash and see lots of examples: