Generated by Spark: It's supposed to accept interactive real time input, instead I get Traceback (most recent call last):

File "/lib/python313.zip/_pyodide/_base.py", line 523, in eval_code
    .run(globals, locals)
     ~~~^^^^^^^^^^^^^^^^^
  File "/lib/python313.zip/_pyodide/_base.py", line 357, in run
    coroutine = eval(self.code, globals, locals)
  File "<exec>", line 3, in <module>
ImportError: cannot import name '__js_input__' from 'js' (unknown location)
This commit is contained in:
2026-01-17 19:51:11 +00:00
committed by GitHub
parent 6b2ee2a29f
commit 031ca48ee5

View File

@@ -139,16 +139,18 @@ sys.stderr = InteractiveStderr(__error_callback__)
pyodide.runPython(`
import builtins
from js import __js_input__
import asyncio
async def custom_input_async(prompt=""):
sys.stdout.write(prompt)
sys.stdout.flush()
from js import __js_input__
result = await __js_input__(prompt)
return result
def custom_input(prompt=""):
import asyncio
loop = asyncio.get_event_loop()
result = loop.run_until_complete(custom_input_async(prompt))
return result