I want to use the FileUpload
widget in jupyter lab.
I have the following lines of code in my notebook cell:
uploader = widgets.FileUpload() uploader
In jupyter notebook, the output of the cell is a clickable button that I can use to upload a file. In jupyter lab, the output is the following :
FileUpload(value={}, description='Upload')
Here’s the info on the uploader
object :
Type: FileUpload String form: FileUpload(value={}, description='Upload') File: ~/miniconda3/envs/fastai2/lib/python3.7/site-packages/ipywidgets/widgets/widget_upload.py
Is it possible to make this widget work on jupyter lab? And if so how should I proceed ?
Advertisement
Answer
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:
- Install nodeJS
pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension
jupyter labextension install @jupyter-widgets/jupyterlab-manager
- (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.