<button id="button" type = "button" class="btn btn-primary" pys-onClick="run_python">
NEXT </button>
<py-script>
from PIL import Image
op = Element("output")
def run_python(*args,**kwargs):
image = Image.open("home/saikumar/Desktop/screenshot/selenium1.jpg"/)
image.show()
</py-script>
I am trying to open the screenshot image which is present in my local directory using the PIL module by clicking button but I am unable open and getting error like "file not found" and I have to open the screenshot by clicking NEXT button.
Error case:
Uncaught PythonError: Traceback (most recent call last):
File "<exec>", line 4, in run_python
File "/lib/python3.10/site-packages/PIL/Image.py", line 3068, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 44] No such file or directory: 'home/saikumar/Desktop/screenshot/selenium1.jpg'
at new_error (pyodide.asm.js:14:238191)
at pyodide.asm.wasm:0xedbcb
at pyodide.asm.wasm:0xedccc
at Module._pythonexc2js (pyodide.asm.js:14:932707)
at Module.callPyObjectKwargs (pyproxy.gen.ts:374:12)
at Module.callPyObject (pyproxy.gen.ts:384:17)
at PyProxyClass.apply (pyproxy.gen.ts:1145:19)
at Object.apply (pyproxy.gen.ts:1022:18)
new_error @ pyodide.asm.js:14
$wrap_exception @ pyodide.asm.wasm:0xedbcb
$pythonexc2js @ pyodide.asm.wasm:0xedccc
Module._pythonexc2js @ pyodide.asm.js:14
Module.callPyObjectKwargs @ pyproxy.gen.ts:374
Module.callPyObject @ pyproxy.gen.ts:384
apply @ pyproxy.gen.ts:1145
apply @ pyproxy.gen.ts:1022