Error message when running via Voila but the notebook is working well at Jupyter

I am currently working on FileUpload/download from ipywidgets. When I run my notebook at Jupyter, the notebook is going well but when I tried to run this notebook via Voila. The error message ‘here was an error when executing cell [8]’ appeared. Moreover, the notebook supports to have both upload and download button but only upload button showed via Voila. The link for my notebook is GitHub - yuxuan7z/communication_voila Really appreciate any suggestion on my notebook. Thank you :grinning:

What do you specifically mean by “When I run my notebook at Jupyter”? What is your “at Jupyter”?

If you are getting an error message when trying to use Voila I’m not seeing how you get to see it doesn’t show a download button. It usually won’t open if there is an error.

When I run your code in JupyterLab and Voila, I get the this error below, which is different than report:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
/tmp/ipykernel_167/702361175.py in <module>
      2 import pandas as pd
      3 
----> 4 uploaded_file = upload.value[0]
      5 
      6 

IndexError: tuple index out of range

So what your are seeing isn’t reproducible.

If I change the code to rely on actual csv file to be read in as df (since upload step fails) then the rest of the code works in JupyterLab. It saves a smaller version of the dataframe I used in the df = pd.read_csv line in the same directory alongside the notebook I was working in. Saves it as output.csv.

If I remove the code with the upload button and the line uploaded_file = upload.value[0]. Then everything runs in Voila and it saves the out.csv file again when I press the Download File button.


You can see the same thing in launches from your repo here.
Although clicking on the Voila icon won’t give the specific error. Given everything else seems the same, from where I ran it, I assume it is the same error in Voila that the notebook gives. Where I ran your notebook and tested I had the this file jupyter_config.json in the root of my repo so the Voila errors were more informative.

1 Like

Thank you so much for your reply. I did not state my myself clearly. I try to create a notebook includes both upload and download button. When I run this notebook at Jupyter notebook, I could see both buttons but when I opened this notebook via voila, only upload button showed with error message ‘tuple out of index’. I could not figure out why there is an error message only appears via voila. Is the mistake part about upload button? Thank you

I put a link where you can see exactly what I see (by clicking here).
The Download button code won’t run to make that button display because it is downstream of the upload button that has an error. It’s just like a normal notebook. It kicks out at the first error and so it doesn’t try to do things past that.
You still haven’t described what you mean by “at Jupyter”?

‘at Jupyter’ I mean when I run the notebook at Jupyter notebook there is no error but error message showed via voila. Now I got your point. Yes, the notebook you had is the same as I have. Could you please guide me how to avoid this error message ‘tuple out of index’? Really appreciate it.

It seems like voila run all cells from the notebook at the same time to me. That’s why the error message ‘tuple out of index’ because there is no file for download button to download. But Jupyter Notebook run cells one by one and so upload file is ready to download

Yes, exactly. Voila runs all the code first to initiate things. You have to build in methods to deal with that and then how to handle the next steps. It seems you are just using some basic code that makes the buttons themselves and not building in the handling. See the thread here from this point forward to give you some pointers how to deal with the upload.