0

From the ipywidgets guide for users I copied and run

import ipywidgets as widgets
widgets.FileUpload(
    accept='',  # Accepted file extension e.g. '.txt', '.pdf', 'image/*', 'image/*,.pdf'
    multiple=False  # True to accept multiple files upload else False
)

But I get the error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-db1cf4369e31> in <module>
      1 import ipywidgets as widgets
----> 2 widgets.FileUpload(
      3     accept='',  # Accepted file extension e.g. '.txt', '.pdf', 'image/*', 'image/*,.pdf'
      4     multiple=False  # True to accept multiple files upload else False
      5 )

AttributeError: module 'ipywidgets' has no attribute 'FileUpload'

What might be the reason for this error? Any pointers would be great.

I'm running jupyter notebook with Python 3 kernel.

user17161
  • 21
  • 2

2 Answers2

2

Update ipywidgets package to version 7.5 (or newer). FileUpload was introduced in that version.

alex
  • 10,900
  • 15
  • 70
  • 100
0

It worked for me:

!pip install ipywidgets
import ipywidgets as widgets
btn_upload = widgets.FileUpload()
btn_upload