I built a custom wheel of dlib package:ML-python-wheels/dlib-19.24.99-cp39-cp39-linux_x86_64.whl at main · dnabanita7/ML-python-wheels · GitHub
I want to install it using micropip but I am not sure why it is giving me errors.
After installing, how to use it as pyimport is deprecated?
<script>
const python_code = `
import numpy as np
import cv2
import micropip
micropip.install('https://github.com/dnabanita7/ML-python-wheels/blob/main/dlib-19.24.99-cp39-cp39-linux_x86_64.whl')
import dlib
np.ones([3,3])
`;
(async () => {
const pyodide = await loadPyodide();
await pyodide.loadPackagesFromImports(python_code)
const result = pyodide.runPython(python_code)
console.log(result.toJs())
})()
</script>
Hello @dashnabanita , and welcome to the forum! A couple of thoughts:
What errors specifically are you seeing? The errors I see (when I also include a Pyodide script tag) are:
(Warning): pyodide.asm.js:10 <exec>:5: RuntimeWarning: coroutine 'install' was never awaited
(Error): ModuleNotFoundError: No module named 'dlib'
The two are releated: micropip.install() is an async function, and must be awaited to be run. In your case, I’d add await micropip.install...
and then use pyodide.runPythonAsync
instead of runPython
to wrap your code up into a coroutine and run it.
And because micropip.install isn’t finishing, the wheel cannot be installed, and the dlib
module cannot be found.
If you do await micropip.install
though, you’ll see another error:
ValueError: Wheel platform 'linux_x86_64' is not compatible with Pyodide's platform 'emscripten-3.1.27-wasm32'
Are you using the Pyodide Build package to build your custom wheel for Pyodide/Emscripten? You’ll likely want to use that to build the wheel in the correct format.
Additionally - the Pyoddie 22.0 stable release just happened/is happening today, and it looks like some of the resources are still being deployed. Just for reference - are you using v0.21.3 or trying with the new Pyodide v0.22.0?