How do I add more modules in Jupyter-Lite? ive tried most variations.
and does Jupyter-Lite use the python libraries on my machine?
I expected Jupyer-lite in the browser to use my python libraries installed locally , like in , Jupyter-lab if I issued the import command in Jupyyer-lite to import them in
JupyterLite cannot really see your system files due to the browser sandboxing it runs in. (In fact, one of the big things being focused on is making it possible to interact better with local storage.) Therefore, it cannot use your libraries installed locally at this time. (Not to mention, they wouldn't be compiled on your system to use webassembly and thus incompatible.)
A lot of the modules in the Python data science stack has already been converted to WebAssembly support.
You can see example of how to install several of these exploring the example notebooks in the pyodide
directory available from here.
You formerly would use piplite
which is a wrapper around micropip
. (piplite
being a wrapper was previously stated here; I think now here is the closest thing to it in the current iteration of the documentation.)
Here's how it was suggested to install several at that time:
import piplite
await piplite.install('numpy')
await piplite.install('pandas')
await piplite.install('matplotlib')
await piplite.install('bokeh')
This is a rapidly developing ecosystem, and so it helps to keep following the updates in a thread at the Jupyter Discourse Forum. Following Jeremy Tuloup on Twitter is highly recommended as well.
I have seen this also suggested more recently to take advantage of the more user-friendly option that is consistent with the non-WASM-based domain of Jupyter:
%pip install -q snowballstemmer rich
To check what is installed, you can use the following, which works no matter if you used await piplite.install()
or %pip install
:
help("modules")
That's based on here.
(As far as I know %pip list
doesn't work at this time in JupyterLite.)
Usage tip
Note that I refer to a current site offering JupyterLite here. (The source repo for that one is actually here and it results in a differently-sources 'session' than the one available from the links in the upper left of the main JupyterLite documentation. ) If you fear you may have already accessed this page and edited some and lost track which are the official versions of the notebooks vs. those you edited, a nice trick is to access the site in an incognito window on your computer. Those windows won't be linked to your browser cache for that site and so you get a 'clean' version of what is currently available from the location. Another trick is to switch use a different source of JupyterLite if one is giving you trouble or hanging up. I have linked to two in the paragraph alone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With