Dash MultiPage Jupyter

How do we use .ipynb(jupyter notebook) in multipage dash setup?. I tried with jupyter it throws error

AttributeError: module '__main__' has no attribute '__file__'

Is there a specific way that dash multipage should be implemented in jupyter?If so please help.
Thankyou!

Hello @H4CK3R !

According to update notes jupyter does not support multipage setup of Dash.

2 Likes

Hi @H4CK3R!

Out of curiosity, why do you want to use jupyter? Actually I’ve been asking myself this question for a while now with every jupyter related topic.

1 Like

wait bro hold on… now i am curious…why not jupyter?

  1. notebooks are usually well organised
  2. they display the output right after execution in the notebook itself and i personally catch errors better in jupyter.
  3. line and cell magics and shell commands imo is best features of notebooks.

Why do you not prefer jupyter bro? may i know bro? :slightly_smiling_face:

For anyone whos using notebook until the feature is released for notebooks. you can use colab-convert instead of nbconvert or vscode export as colab-convert comments out magic commands. to automate conversion of .ipynb files, you can add this in app.py.

from glob import glob
import subprocess


files = glob('./pages/*.ipynb')
for file_ in files:
    py_file_name =  "."  +  file_.split('.')[-2] + ".py" # find the file and name it 
    subprocess.run("colab-convert "+file_+" "+py_file_name,shell=True )

# rest of the dash app

also add debug=False as it refershes at intervals
colab-convert seems to run again and again making the webpage unresponsive.
you can just make changes in your .ipynb files then save and run the app.py
it is temporary fix but the feature will definitely be available soon as i have immense trust in plotly team

1 Like