最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

local - Can't get pyscript to import a simple module in the same directory. I see this question all over, but none of th

programmeradmin3浏览0评论

Should be pretty straight forward, but I keep getting this modulenotfound error. And it looks like every year they change the way to do it and deprecate all other ways.

This is my index.html

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href=".3.1/core.css" />
        <script type="module" src=".3.1/core.js"></script>
    </head>
    <body>
        
        <button id="button">¡Di Hola!</button>
        <div id="saludo"></div>
        
        <!-- Cargamos un módulo propio antes del código python -->
        <py-import src="/hazAlgo.py"></py-import>
        
        <!-- Aquí va el código python -->
        <py-script>
            from js import document
            from pyodide.ffi.wrappers import add_event_listener
            import hazAlgo
    
            hazAlgo.hola()

            btn = document.getElementById("button")
            add_event_listener(btn, "click", hola)
        </py-script>
    </body>
</html>

hazAlgo.py is located in the same folder as index.html

I tried using the <py-import src="/hazAlgo.py"></py-import> tag that both Gemini and ChatGPT insist should be working, but they can't help me fix it.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论