首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在PyScript中抑制Pyodide警告?

如何在PyScript中抑制Pyodide警告?
EN

Stack Overflow用户
提问于 2022-11-23 08:17:15
回答 1查看 31关注 0票数 0

我有下面的PyScript + HTML示例,并得到以下错误:

代码语言:javascript
复制
/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(

我如何能够抑制/删除警告?

为什么当我使用:时也会出现这个错误

代码语言:javascript
复制
from pyodide.ffi import create_proxy
代码语言:javascript
复制
<!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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-11-23 08:57:38

这个问题已经在pyscript#867中解决了,修复应该包含在下一个版本中。

否则,您可以尝试完全禁用所有警告,

代码语言:javascript
复制
import warnings
warnings.filterwarnings("ignore")

但我不确定它在<py-script>标记中是否会被提前调用。

另一个解决方案是构建最新的pyscript版本,其中包括修复程序,并使用该版本。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74543624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档