description
Hi all,
I’m trying to debug why the value returns None
when I use this FileInput
widget in this code block
!pip install panel watchfiles -U
!pip install -U jupyterlab
!pip install panel param bokeh jupyter_bokeh -U
import panel as pn
pn.extension()
pn.extension('tabulator')
import pandas as pd
xml_files = pn.widgets.FileInput(multiple=True)
xml_files
print(xml_files.value)
I do not encounter this issue when I run the same code above in a local vscode notebook. I’m not sure if the issue is with GCP or Jupyter as I’ve upgraded to the latest version of all packages
Chatgpt suggested running this code to listen for any uploads, but it fails
import panel as pn
import time
import threading
# Initialize the Panel extension
pn.extension()
# Create the FileInput widget
file_input = pn.widgets.FileInput(accept='.xml')
# Function to handle file uploads
def handle_file(event):
print(f"Event new value: {event.new}") # Debug statement
if event.new:
file_name = event.new.filename
print(f"File name: {file_name}") # Debug statement
try:
file_contents = event.new.read() # Read file contents
print(f"File contents: {file_contents.decode('utf-8')}")
except Exception as e:
print(f"Error reading file: {e}")
else:
print("No file uploaded")
file_input.param.watch(handle_file, 'value')
layout = pn.Column(
pn.pane.Markdown("## Upload a file"),
file_input
)
# Display the layout
pn.Row(layout).servable()
# Function to check and print the value of file_input periodically
def check_value():
for _ in range(10): # Check 10 times with a 5-second interval
print(f"file_input.value: {file_input.value}")
time.sleep(5)
# Run the value check function in a non-blocking way
thread = threading.Thread(target=check_value)
thread.start()
layout
it prints out None
I’ll post the environment info in a follow post
Software info
pip packages
pip list freeze
Package Version
absl-py 2.1.0
aiohttp 3.9.5
aiohttp-cors 0.7.0
aiosignal 1.3.1
annotated-types 0.6.0
anyio 3.7.1
archspec 0.2.3
argon2-cffi 23.1.0
argon2-cffi-bindings 21.2.0
arrow 1.3.0
asttokens 2.4.1
async-lru 2.0.4
async-timeout 4.0.3
attrs 23.2.0
Babel 2.15.0
backports.tarfile 1.1.1
beautifulsoup4 4.12.3
bleach 6.1.0
blessed 1.20.0
bokeh 3.4.1
boltons 24.0.0
bq_stats 1.0
Brotli 1.1.0
brotlipy 0.7.0
cached-property 1.5.2
cachetools 5.3.3
certifi 2024.2.2
cffi 1.16.0
charset-normalizer 3.3.2
click 8.1.7
cloud-tpu-client 0.10
cloudpickle 3.0.0
colorama 0.4.6
colorful 0.5.6
comm 0.2.2
conda 24.5.0
conda-content-trust 0+unknown
conda-libmamba-solver 24.1.0
conda-package-handling 2.2.0
conda_package_streaming 0.9.0
contourpy 1.2.1
cryptography 42.0.7
cycler 0.12.1
dacite 1.8.1
db-dtypes 1.2.0
debugpy 1.8.1
decorator 5.1.1
defusedxml 0.7.1
Deprecated 1.2.14
distlib 0.3.8
distro 1.9.0
dm-tree 0.1.8
dnspython 2.6.1
docker 7.0.0
docstring_parser 0.16
email_validator 2.1.1
entrypoints 0.4
exceptiongroup 1.2.0
executing 2.0.1
Farama-Notifications 0.0.4
fastapi 0.111.0
fastapi-cli 0.0.3
fastjsonschema 2.19.1
filelock 3.14.0
fonttools 4.51.0
fqdn 1.5.1
frozendict 2.4.4
frozenlist 1.4.1
fsspec 2024.3.1
gcsfs 2024.3.1
gitdb 4.0.11
GitPython 3.1.43
google-api-core 1.34.1
google-api-python-client 1.8.0
google-auth 2.29.0
google-auth-httplib2 0.2.0
google-auth-oauthlib 1.2.0
google-cloud-aiplatform 1.51.0
google-cloud-artifact-registry 1.11.3
google-cloud-bigquery 3.22.0
google-cloud-bigquery-storage 2.25.0
google-cloud-core 2.4.1
google-cloud-datastore 1.15.5
google-cloud-language 2.13.3
google-cloud-monitoring 2.21.0
google-cloud-resource-manager 1.12.3
google-cloud-storage 2.14.0
google-crc32c 1.5.0
google-resumable-media 2.7.0
googleapis-common-protos 1.63.0
gpustat 1.0.0
greenlet 3.0.3
grpc-google-iam-v1 0.13.0
grpcio 1.63.0
grpcio-status 1.48.2
gymnasium 0.28.1
h11 0.14.0
htmlmin 0.1.12
httpcore 1.0.5
httplib2 0.22.0
httptools 0.6.1
httpx 0.27.0
idna 3.7
ImageHash 4.3.1
imageio 2.34.1
importlib-metadata 7.0.0
importlib_resources 6.4.0
ipykernel 6.29.3
ipython 8.21.0
ipython-genutils 0.2.0
ipython-sql 0.5.0
ipywidgets 8.1.2
isoduration 20.11.0
jaraco.classes 3.4.0
jaraco.context 5.3.0
jaraco.functools 4.0.1
jax-jumpy 1.0.0
jedi 0.19.1
jeepney 0.8.0
Jinja2 3.1.4
joblib 1.4.2
json5 0.9.25
jsonpatch 1.33
jsonpointer 2.4
jsonschema 4.22.0
jsonschema-specifications 2023.12.1
jupyter_bokeh 4.0.5
jupyter_client 7.4.9
jupyter_core 5.7.2
jupyter-events 0.10.0
jupyter-lsp 2.2.5
jupyter_server 2.14.0
jupyter-server-mathjax 0.2.6
jupyter_server_terminals 0.5.3
jupyterlab 4.2.1
jupyterlab_pygments 0.3.0
jupyterlab_server 2.27.1
jupyterlab_widgets 3.0.10
keyring 25.2.1
keyrings.google-artifactregistry-auth 1.1.2
kfp 2.5.0
kfp-pipeline-spec 0.2.2
kfp-server-api 2.0.5
kiwisolver 1.4.5
kubernetes 26.1.0
lazy_loader 0.4
libmambapy 1.5.8
linkify-it-py 2.0.3
llvmlite 0.42.0
lz4 4.3.3
Markdown 3.6
markdown-it-py 3.0.0
MarkupSafe 2.1.5
matplotlib 3.8.4
matplotlib-inline 0.1.7
mdit-py-plugins 0.4.1
mdurl 0.1.2
memray 1.12.0
menuinst 2.0.2
mistune 3.0.2
more-itertools 10.2.0
msgpack 1.0.8
multidict 6.0.5
multimethod 1.11.2
nb_conda 2.2.1
nb_conda_kernels 2.5.1
nbclassic 1.0.0
nbclient 0.10.0
nbconvert 7.16.4
nbdime 3.2.0
nbformat 5.10.4
nest-asyncio 1.6.0
networkx 3.3
notebook 6.5.6
notebook_shim 0.2.4
numba 0.59.1
numpy 1.26.4
nvidia-ml-py 11.495.46
oauth2client 4.1.3
oauthlib 3.2.2
opencensus 0.11.4
opencensus-context 0.1.3
opentelemetry-api 1.24.0
opentelemetry-exporter-otlp 1.24.0
opentelemetry-exporter-otlp-proto-common 1.24.0
opentelemetry-exporter-otlp-proto-grpc 1.24.0
opentelemetry-exporter-otlp-proto-http 1.24.0
opentelemetry-proto 1.24.0
opentelemetry-sdk 1.24.0
opentelemetry-semantic-conventions 0.45b0
orjson 3.10.3
overrides 7.7.0
packaging 24.0
pandas 2.2.2
pandas-profiling 3.6.6
pandocfilters 1.5.0
panel 1.4.4
param 2.1.0
parso 0.8.4
patsy 0.5.6
pexpect 4.9.0
phik 0.12.4
pickleshare 0.7.5
pillow 10.3.0
pip 24.0
pkgutil_resolve_name 1.3.10
platformdirs 4.2.1
plotly 5.22.0
pluggy 1.5.0
prettytable 3.10.0
prometheus_client 0.20.0
prompt-toolkit 3.0.42
proto-plus 1.23.0
protobuf 3.20.3
psutil 5.9.3
ptyprocess 0.7.0
pure-eval 0.2.2
py-spy 0.3.14
pyarrow 16.1.0
pyasn1 0.6.0
pyasn1_modules 0.4.0
pycosat 0.6.6
pycparser 2.22
pydantic 2.7.1
pydantic_core 2.18.2
Pygments 2.18.0
pyOpenSSL 24.0.0
pyparsing 3.1.2
PySocks 1.7.1
python-dateutil 2.9.0
python-dotenv 1.0.1
python-json-logger 2.0.7
python-multipart 0.0.9
pytz 2024.1
pyviz_comms 3.0.2
PyWavelets 1.6.0
PyYAML 6.0.1
pyzmq 24.0.1
ray 2.22.0
ray-cpp 2.22.0
referencing 0.35.1
requests 2.31.0
requests-oauthlib 2.0.0
requests-toolbelt 0.10.1
retrying 1.3.4
rfc3339-validator 0.1.4
rfc3986-validator 0.1.1
rich 13.7.1
rpds-py 0.18.1
rsa 4.9
ruamel.yaml 0.18.6
ruamel.yaml.clib 0.2.8
ruamel-yaml-conda 0.15.100
scikit-image 0.23.2
scikit-learn 1.4.2
scipy 1.13.0
seaborn 0.13.2
SecretStorage 3.3.3
Send2Trash 1.8.3
setuptools 69.5.1
shapely 2.0.4
shellingham 1.5.4
six 1.16.0
smart-open 7.0.4
smmap 5.0.1
sniffio 1.3.1
soupsieve 2.5
SQLAlchemy 2.0.30
sqlparse 0.5.0
stack-data 0.6.2
starlette 0.37.2
statsmodels 0.14.2
tabulate 0.9.0
tenacity 8.3.0
tensorboardX 2.6.2.2
terminado 0.18.1
textual 0.60.0
threadpoolctl 3.5.0
tifffile 2024.5.10
tinycss2 1.3.0
tomli 2.0.1
tornado 6.4
tqdm 4.66.4
traitlets 5.14.3
truststore 0.8.0
typeguard 4.2.1
typer 0.12.3
types-python-dateutil 2.9.0.20240316
typing_extensions 4.11.0
typing-utils 0.1.0
tzdata 2024.1
uc-micro-py 1.0.3
ujson 5.10.0
uri-template 1.3.0
uritemplate 3.0.1
urllib3 1.26.18
uvicorn 0.29.0
uvloop 0.19.0
virtualenv 20.26.2
visions 0.7.6
watchfiles 0.22.0
wcwidth 0.2.13
webcolors 1.13
webencodings 0.5.1
websocket-client 1.8.0
websockets 12.0
wheel 0.43.0
widgetsnbextension 4.0.10
wordcloud 1.9.3
wrapt 1.16.0
xyzservices 2024.4.0
yarl 1.9.4
ydata-profiling 4.8.3
zipp 3.17.0
zstandard 0.22.0
I’ll post the web console log and conda info in a subsequent posts
conda environment info
conda info
active environment : base
active env location : /opt/conda
shell level : 4
user config file : /home/jupyter/.condarc
populated config files : /opt/conda/.condarc
conda version : 24.5.0
conda-build version : not installed
python version : 3.10.14.final.0
solver : libmamba (default)
virtual packages : __archspec=1=broadwell
__conda=24.5.0=0
__glibc=2.31=0
__linux=5.10.0=0
__unix=0=0
base environment : /opt/conda (writable)
conda av data dir : /opt/conda/etc/conda
conda av metadata url : None
channel URLs : https://conda.anaconda.org/nodefaults/linux-64
https://conda.anaconda.org/nodefaults/noarch
https://conda.anaconda.org/conda-forge/linux-64
https://conda.anaconda.org/conda-forge/noarch
package cache : /opt/conda/pkgs
/home/jupyter/.conda/pkgs
envs directories : /opt/conda/envs
/home/jupyter/.conda/envs
platform : linux-64
user-agent : conda/24.5.0 requests/2.31.0 CPython/3.10.14 Linux/5.10.0-29-cloud-amd64 debian/11.9 glibc/2.31 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.8
UID:GID : 1000:1001
netrc file : None
offline mode : False