我知道使用Pyodide我可以:
micropip
A)通过从 PyPI 或.whl
文件的 URL安装纯 Python 包
例子:
pyodide.runPythonAsync(`
import micropip
await micropip.install('pyicloud')
`);
B) 如果包是用 Pyodide 构建的并且存在于 Pyodide 存储库中,则加载具有本机扩展的包:
例子:
pyodide.loadPackage(
[
"pandas",
]
);
但是,您如何处理既不是 A) 也不是 B) 的依赖关系的情况?
示例:my_new_library
需要sqlmodel
哪些需要sqlalchemy
具有本机扩展但不在 Pyodide 的预构建包列表中。
因此,如果我尝试使用 micropip 安装.whl
of my_new_library
,我会在 JavaScript 控制台上收到以下错误:
pyodide.asm.js:14 Uncaught (in promise) PythonError: Traceback (most recent call last):
File "/lib/python3.9/asyncio/futures.py", line 201, in result
raise self._exception
File "/lib/python3.9/asyncio/tasks.py", line 258, in __step
result = coro.throw(exc)
File "/lib/python3.9/site-packages/_pyodide/_base.py", line 494, in eval_code_async
await CodeRunner(
File "/lib/python3.9/site-packages/_pyodide/_base.py", line 347, in run_async
await coroutine
File "<exec>", line 3, in <module>
File "/lib/python3.9/asyncio/futures.py", line 284, in __await__
yield self # This tells Task to wait for completion.
File "/lib/python3.9/asyncio/tasks.py", line 328, in __wakeup
future.result()
File "/lib/python3.9/asyncio/futures.py", line 201, in result
raise self._exception
File "/lib/python3.9/asyncio/tasks.py", line 256, in __step
result = coro.send(None)
File "/lib/python3.9/site-packages/micropip/_micropip.py", line 191, in install
raise ValueError(
ValueError: Couldn't find a pure Python 3 wheel for: 'sqlalchemy<1.5.0,>=1.4.17'
at new_error (pyodide.asm.js:14)
at pyodide.asm.wasm:0xe6eb0
at pyodide.asm.wasm:0xeacfd
at method_call_trampoline (pyodide.asm.js:14)
at pyodide.asm.wasm:0x121318
at pyodide.asm.wasm:0x209acf
at pyodide.asm.wasm:0x160f8b
at pyodide.asm.wasm:0x121865
at pyodide.asm.wasm:0x12195f
at pyodide.asm.wasm:0x121a2d