0

knowing that with <py-config> and <py-script> can execute python code in html


However, importing own function facing error
(PY1001): Unable to install package(s) 'bread'. Reason: Can't find a pure Python 3 Wheel for package(s) 'bread'. See: https://pyodide.org/en/stable/usage/faq.html#micropip-can-t-find-a-pure-python-wheel for more information.

  • html script
<html>
    <head>
      <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
      <script defer src="https://pyscript.net/latest/pyscript.js"></script>
    </head>

  <body>
    <b><p>title <u><label id="AAA"></label></u> </p></b>
    <br>
  
    <py-config>

      packages = ["bread"]
    </py-config>


    <py-script>
        import bread.py
        bread.fun_1()

    </py-script>
  </body>
</html>
  • own python script "bread.py"
def fun_1():
    print("this is bread")

(pic) the result screenshot for above code


if I import my own function in another .py script is working, but do the same thing into html not works
(pic) the result that import my own function in another .py script is fine

I read through the link system recommend link, and link but I can't find out the solution myself, that I need a hand for this problem, thanks

1 Answer 1

0

The reason you are getting the error is that PyScript thinks you want to import a third-party package.

To import your custom modules, use [[fetch]] in your <py-config> and replace packages with files.


<py-config>
  [[fetch]]
  files = ["./bread.py"]
</py-config>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.