I have the following PyScript + HTML example and I get the following error:
/lib/python3.10/site-packages/pyodide/__init__.py:74: FutureWarning: pyodide.create_proxy has been moved to pyodide.ffi.create_proxy Accessing it through the pyodide module is deprecated. warn(
How I can suppress/remove the warning?
Why I get this error even when I use:
from pyodide.ffi import create_proxy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>PyScript Pyodide Warning</title>
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
</head>
<body>
<h1>PyScript - Pyodide Warnning</h1>
<input id="inp-cheese" type="text" placeholder="Want cheese? y|n">
<input id="inp-bacon" type="text" placeholder="Want bacon? y|n">
<input id="inp-mashrooms" type="text" placeholder="Want mashrooms? y|n">
<input id="inp-paper" type="text" placeholder="Want paper? y|n">
<button id="btn2" class="button-14" role="button">Go</button>
<py-script>
from pyodide.ffi import create_proxy
from js import document
def on_btn2_click(event):
global cheese
global bacon
global mashrooms
global paper
input_cheese = Element("inp-cheese")
input_bacon = Element("inp-bacon")
input_mashrooms = Element("inp-mashrooms")
input_paper = Element("inp-paper")
cheese = input_cheese.value
bacon = input_bacon.value
mashrooms = input_mashrooms.value
paper = input_paper.value
button2 = document.querySelector("#btn2")
button2.addEventListener("click", create_proxy(on_btn2_click))
</py-script>
<py-repl id="my-repl-23nov22-0931" auto-generate="true">
if cheese == 'y':
print("+ Cheese")
if bacon == 'y':
print("+ Bacon")
if mashrooms == 'y':
print("+ Mashrooms")
if paper == 'y':
print("+ Paper")
print("_____")
</py-repl>
</body>
</html>
This issue was fixed in pyscript#867 and the fix should be included in the next release.
Otherwise, you could try to disable all warnings altogether,
import warnings
warnings.filterwarnings("ignore")
but I'm not sure it would be called early enough in the <py-script>
tag.
The other solution is to build the latest pyscript version, which includes the fix, and use that.