I am using the IPython file upload widget package to upload a text file but I can not see the upload widget button after running the upload() function. In the package library, it is asking to enable "jupyter nbextension enable" and I've enabled it still not working. Below is my code with output:
import io
from IPython.display import display
import fileupload
The output of the above code is below:
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
After this output I used Upload() function in next cell and the code is below:
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()
After this code, the widget button was expected to show up but I can not see that button. Please help me to understand what wrong I am doing?
Thanks!