我有下面的PyScript + HTML示例,并得到以下错误:
/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(我如何能够抑制/删除警告?
为什么当我使用:时也会出现这个错误
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>发布于 2022-11-23 08:57:38
这个问题已经在pyscript#867中解决了,修复应该包含在下一个版本中。
否则,您可以尝试完全禁用所有警告,
import warnings
warnings.filterwarnings("ignore")但我不确定它在<py-script>标记中是否会被提前调用。
另一个解决方案是构建最新的pyscript版本,其中包括修复程序,并使用该版本。
https://stackoverflow.com/questions/74543624
复制相似问题