【问题标题】:The ipywidgets function FileUpload is not found when run on Jupyter notebook在 Jupyter notebook 上运行时找不到 ipywidgets 函数 FileUpload
【发布时间】:2019-12-21 10:29:11
【问题描述】:

来自我复制并运行的用户的 ipywidgets 指南

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
)

但我得到了错误

---------------------------------------------------------------------------
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'

此错误的原因可能是什么?任何指针都会很棒。

我正在运行带有 Python 3 内核的 jupyter notebook。

【问题讨论】:

    标签: python file-upload jupyter-notebook ipywidgets


    【解决方案1】:

    ipywidgets 包更新到版本 7.5(或更高版本)。 FileUpload 是在那个版本中引入的。

    【讨论】:

      【解决方案2】:

      它对我有用:

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

      【讨论】:

        猜你喜欢
        • 2021-02-06
        • 1970-01-01
        • 2019-04-14
        • 2016-06-13
        • 1970-01-01
        • 2017-10-04
        • 2017-10-29
        • 1970-01-01
        • 2018-09-25
        相关资源
        最近更新 更多