How to use FileUpload widget in jupyter lab?

For me it worked after

pip install jupyterlab-widgets
jupyter labextension install @jupyter-widgets/jupyterlab-manager

Also see


from ipywidgets import FileUpload
from IPython.display import display
upload = FileUpload(accept='.txt', multiple=True)

with open('z_merged_output.txt', 'wb') as output_file: 
    for uploaded_filename in upload.value:
        content = upload.value[uploaded_filename]['content']   

enter image description here

If you're using jupyterlab out the box, it doesn't have ipywidgets enabled by default, you need to rebuild it after enabling the extension. Follow the steps from here:

  1. Install nodeJS
  2. pip install ipywidgets
  3. jupyter nbextension enable --py widgetsnbextension
  4. jupyter labextension install @jupyter-widgets/jupyterlab-manager
  5. (may need to restart your lab)

It says that newer Jupyterlab has it enabled, but I still had troubles with it, depending on the platform. Manual install is usually the way to go.