Giter Site home page Giter Site logo

Comments (2)

zloveless avatar zloveless commented on July 27, 2024 1

Hi @mneil, this seems to work, thanks! My handleSubmit() now looks like this:

  const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
    e.preventDefault();
    const pyodide = await loadPyodide({
      indexURL: 'https://cdn.jsdelivr.net/pyodide/v0.26.1/full/'
    });
    await pyodide.loadPackage('micropip');
    pyodide.pyimport('micropip');
    const wheel = 'my-redacted-wheel.whl'; // TODO!
    pyodide.loadPackage(wheel);
    pyodide.runPython(codeModel);
  };

from pyodide-webpack-plugin.

mneil avatar mneil commented on July 27, 2024

Hi @zloveless, thanks for raising this issue. The documentation could be clearer about this.

The first screenshot you have shows that these files are missing from your local dev server. The examples show basic usage of pyodide and the plugin without any other packages installed. I realize once you start actually adding packages and micropip it gets more complicated.

By default, pyodide (not the plugin) tries to load packages like micropip and other pip packages local to the pyodide.js location. What that means is you would need to download or build micropip and place it at some path available on your dev server, typically /micropip-0.6.0-py3-none-any.whl or similar by default. The examples show changing that indexURL to keep packages out of the root / folder and placing them in /pyodide for organization.

I will note for security this is preferred and is intended behavior. See supply chain security

What you might be interested in for simple testing and verification of the tool is to use the CDN hosted packages that pyodide provides. You can do that by setting the indexURL in your handleSubmit function to https://cdn.jsdelivr.net/pyodide/v0.26.1/full/. This should get you running again and will provide the same behavior as if you were serving pyodide from the CDN.

Please let me know if that resolves your issue.

from pyodide-webpack-plugin.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.