gpt4 book ai didi

Python 文件上传小部件不工作,它没有在 jupyter notebook 中显示上传按钮

转载 作者:行者123 更新时间:2023-12-05 05:01:56 28 4
gpt4 key购买 nike

我正在使用 IPython 文件上传小部件包上传文本文件,但在运行 upload() 函数后我看不到上传小部件按钮。在包库中,它要求启用“jupyter nbextension enable”,我已经启用它仍然无法正常工作。下面是我的代码输出:

import io
from IPython.display import display
import fileupload

上面代码的输出如下:

Requirement already satisfied: webencodings in /opt/conda/lib/python3.6/site-packages (from bleach-  
to date: /home/jovyan/.local/share/jupyter/nbextensions/fileupload/extension.js
Up to date: /home/jovyan/.local/share/jupyter/nbextensions/fileupload/widget.js
Up to date: /home/jovyan/.local/share/jupyter/nbextensions/fileupload/fileupload/widget.js
- Validating: OK

To initialize this nbextension in the browser every time the notebook (or other app) loads:

jupyter nbextension enable fileupload --user --py

Enabling notebook extension fileupload/extension...
- Validating: OK

在此输出之后,我在下一个单元格中使用了 Upload() 函数,代码如下:

def _upload():

_upload_widget = fileupload.FileUploadWidget()

def _cb(change):
global file_contents
decoded = io.StringIO(change['owner'].data.decode('utf-8'))
filename = change['owner'].filename
print('Uploaded `{}` ({:.2f} kB)'.format(
filename, len(decoded.read()) / 2 **10))
file_contents = decoded.getvalue()

_upload_widget.observe(_cb, names='data')
display(_upload_widget)

_upload()

在这段代码之后,小部件按钮应该会出现,但我看不到那个按钮。请帮助我了解我做错了什么?

谢谢!

最佳答案

完全关闭并重新打开笔记本解决了我的问题。在提交特定的 Coursera 项目期间,这发生在我身上。

关于Python 文件上传小部件不工作,它没有在 jupyter notebook 中显示上传按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62433420/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com