Install with pyodide
See original GitHub issueI was playing around with jupyterlite and tried to install Dask
import micropip
await micropip.install("dask")
I think that it would be fun if we could get dask and distributed running smoothly. My guess is that this is doable if we’re able to package things up in a pure python way, but that currently we’re not in some way.
cc @jakirkham who I suspect understands this space well
Traceback
Traceback (most recent call last):
  File "<console>", line 2, in <module>
  File "/lib/python3.8/asyncio/futures.py", line 260, in __await__
    yield self  # This tells Task to wait for completion.
  File "/lib/python3.8/asyncio/tasks.py", line 349, in __wakeup
    future.result()
  File "/lib/python3.8/asyncio/futures.py", line 178, in result
    raise self._exception
  File "/lib/python3.8/asyncio/tasks.py", line 282, in __step
    result = coro.throw(exc)
  File "/lib/python3.8/site-packages/micropip.py", line 158, in install
    transaction = await self.gather_requirements(requirements, ctx)
  File "/lib/python3.8/site-packages/micropip.py", line 154, in gather_requirements
    await gather(*requirement_promises)
  File "/lib/python3.8/asyncio/futures.py", line 260, in __await__
    yield self  # This tells Task to wait for completion.
  File "/lib/python3.8/asyncio/tasks.py", line 349, in __wakeup
    future.result()
  File "/lib/python3.8/asyncio/futures.py", line 178, in result
    raise self._exception
  File "/lib/python3.8/asyncio/tasks.py", line 280, in __step
    result = coro.send(None)
  File "/lib/python3.8/site-packages/micropip.py", line 227, in add_requirement
    await self.add_requirement(recurs_req, ctx, transaction)
  File "/lib/python3.8/site-packages/micropip.py", line 222, in add_requirement
    wheel, ver = self.find_wheel(metadata, req)
  File "/lib/python3.8/site-packages/micropip.py", line 238, in find_wheel
    release = releases[str(ver)]
KeyError: '3.9'
PythonError: Traceback (most recent call last):
  File "/lib/python3.8/asyncio/futures.py", line 178, in result
    raise self._exception
  File "/lib/python3.8/asyncio/tasks.py", line 282, in __step
    result = coro.throw(exc)
  File "/lib/python3.8/site-packages/pyolite/interpreter.py", line 23, in run
    result = await self.run_complete
  File "/lib/python3.8/asyncio/futures.py", line 260, in __await__
    yield self  # This tells Task to wait for completion.
  File "/lib/python3.8/asyncio/tasks.py", line 349, in __wakeup
    future.result()
  File "/lib/python3.8/asyncio/futures.py", line 178, in result
    raise self._exception
  File "/lib/python3.8/asyncio/tasks.py", line 282, in __step
    result = coro.throw(exc)
  File "/lib/python3.8/site-packages/pyodide/console.py", line 253, in load_packages_and_run
    raise e
  File "/lib/python3.8/site-packages/pyodide/console.py", line 247, in load_packages_and_run
    result = await eval_code_async(
  File "/lib/python3.8/site-packages/pyodide/_base.py", line 419, in eval_code_async
    return await CodeRunner(
  File "/lib/python3.8/site-packages/pyodide/_base.py", line 278, in run_async
    res = await res
  File "<console>", line 2, in <module>
  File "/lib/python3.8/asyncio/futures.py", line 260, in __await__
    yield self  # This tells Task to wait for completion.
  File "/lib/python3.8/asyncio/tasks.py", line 349, in __wakeup
    future.result()
  File "/lib/python3.8/asyncio/futures.py", line 178, in result
    raise self._exception
  File "/lib/python3.8/asyncio/tasks.py", line 282, in __step
    result = coro.throw(exc)
  File "/lib/python3.8/site-packages/micropip.py", line 158, in install
    transaction = await self.gather_requirements(requirements, ctx)
  File "/lib/python3.8/site-packages/micropip.py", line 154, in gather_requirements
    await gather(*requirement_promises)
  File "/lib/python3.8/asyncio/futures.py", line 260, in __await__
    yield self  # This tells Task to wait for completion.
  File "/lib/python3.8/asyncio/tasks.py", line 349, in __wakeup
    future.result()
  File "/lib/python3.8/asyncio/futures.py", line 178, in result
    raise self._exception
  File "/lib/python3.8/asyncio/tasks.py", line 280, in __step
    result = coro.send(None)
  File "/lib/python3.8/site-packages/micropip.py", line 227, in add_requirement
    await self.add_requirement(recurs_req, ctx, transaction)
  File "/lib/python3.8/site-packages/micropip.py", line 222, in add_requirement
    wheel, ver = self.find_wheel(metadata, req)
  File "/lib/python3.8/site-packages/micropip.py", line 238, in find_wheel
    release = releases[str(ver)]
KeyError: '3.9'
    at new_error (https://cdn.jsdelivr.net/pyodide/v0.17.0/full/pyodide.asm.js:9:175413)
    at wrap_exception (https://cdn.jsdelivr.net/pyodide/v0.17.0/full/pyodide.asm.wasm:wasm-function[297]:0x1a6c94)
    at FutureDoneCallback_call (https://cdn.jsdelivr.net/pyodide/v0.17.0/full/pyodide.asm.wasm:wasm-function[379]:0x1aaab3)
    at byn$fpcast-emu$FutureDoneCallback_call (https://cdn.jsdelivr.net/pyodide/v0.17.0/full/pyodide.asm.wasm:wasm-function[14420]:0x7a257c)
    at _PyObject_MakeTpCall (https://cdn.jsdelivr.net/pyodide/v0.17.0/full/pyodide.asm.wasm:wasm-function[760]:0x1cabed)
    at __static_1198 (https://cdn.jsdelivr.net/pyodide/v0.17.0/full/pyodide.asm.wasm:wasm-function[2906]:0x2c54f1)
    at byn$fpcast-emu$__static_1198 (https://cdn.jsdelivr.net/pyodide/v0.17.0/full/pyodide.asm.wasm:wasm-function[22640]:0x7bf866)
    at __static_678 (https://cdn.jsdelivr.net/pyodide/v0.17.0/full/pyodide.asm.wasm:wasm-function[1621]:0x21220e)
    at byn$fpcast-emu$__static_678 (https://cdn.jsdelivr.net/pyodide/v0.17.0/full/pyodide.asm.wasm:wasm-function[22120]:0x7bdce6)
    at PyVectorcall_Call (https://cdn.jsdelivr.net/pyodide/v0.17.0/full/pyodide.asm.wasm:wasm-function[763]:0x1cb006)
Issue Analytics
- State:
 - Created 2 years ago
 - Comments:16 (13 by maintainers)
 
Top Results From Across the Web
Loading packages — Version 0.21.3 - Pyodide
Pyodide supports installing pure Python wheels from PyPI with micropip . micropip.install() returns a Python Future so you can await the future or...
Read more >pyodide - PyPI
pip install pyodide ... Pyodide is a Python distribution that runs in the browser or Node.js. It cannot be installed from PyPi.
Read more >pyodide - npm
Keywords · Install · Repository · Homepage · Weekly Downloads · Version · License · Unpacked Size · Total Files.
Read more >Can't install pyodide-build using the instructions #2020 - GitHub
Bug The pyodide documentation has instruction on how to install the tool pyodide-build. When I run the pip command, I get an error:...
Read more >Installing packages from PyPI - test-pyodide - Read the Docs
Pyodide has experimental support for installing pure Python wheels from PyPI. ... py import micropip micropip.install('snowballstemmer') # Iodide implicitly ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Huzzah, looks like a bunch of the examples Just Work ™️ in jupyterlite today:
And the demo site even has
ipycytoscape:Seems like some hot examples in the docs are more than possible now, akin to what
numpy,pandas,sympyandipywidgetsare doing.If all the dependencies are pure Python and have wheels they would indeed be uninstallable with micropip.
Indeed, it should be resolved with https://github.com/pyodide/pyodide/pull/1181
A complication is that
If tornado doesn’t work (I don’t know much about how it works), I imagine, then one would need to find some alternative for communicating between nodes, possibly with WebSockets?
In the WASM VM, multiprocessing is indeed not supported, threading is not supported yet on all browsers (and not enabled in Pyodide), however there is a possibility to use WebWorkers which also allow to create separate threads although with a different API.
One could be to offload expensive calculations to a cluster. Though in that respect one could also just use jupyter notebook directly with a locally running dask.
Another use case would be to be able to send commands to Python in WASM from Python running locally (or the other way around), for instance for testing https://github.com/pytest-dev/pytest-xdist/issues/336