0

"I'm trying to import the 'PyPDF4' library in Pyodide using micropip but it's giving me an error:

ValueError: Can't find a pure Python 3 wheel for 'pypdf4'.

Would anyone know what I'm doing wrong?"

async function main() {
    let pyodide = await loadPyodide();
    await pyodide.loadPackage('micropip');

    const micropip = pyodide.pyimport("micropip");
    await micropip.install('PyPDF4');

    pyodide.runPython(`
      import PyPDF4
      print(PyPDF4.__version__)
    `);
  }

  main();
rafaelcb21
  • 12,422
  • 28
  • 62
  • 86
  • I strongly suggest using `pypdf`, not `PyPDF4`. Look at the date of the last release, how often in the past years releases were made, the GitHub stars, the answers to issues, the amount of issues ... or just the fact that [pypdf has a pure-python wheel](https://pypi.org/project/pypdf/#files) – Martin Thoma Apr 22 '23 at 16:44

1 Answers1

2

The pypdf4 package, though it appears to be pure-python, isn't distributing a "Pure Python" wheel (ending in -any-none.whl) on PyPi. Micropip can only install packages that are either built in Pyodide or have a pure Python wheel on PyPI.

You have a couple of options, as explained in the Pyodide Docs - building a Python wheel for yourself, or submitting a ticket with the Pyodide maintainers to see if they'll build one for you.

Jeff Glass
  • 622
  • 1
  • 8