1

I am not from IT background and learning python for data analysis and biostats. I started using jupyterlab (https://jupyter.org/try-jupyter/lab). I can install and import few modules like pandas and numpy but can't install ipysheet. I tried few ways like using pip,%pip, piplite.install() but all attempts failed. Can you kindly suggest a way out? Or if you can suggest a way to use spyder online without installation? Many thanks.

  • That what you referencing is VERY EXPERIMENTAL as highlighted on [the main Try Jupyter page](https://jupyter.org/try). And on [the main JupyterLite](https://jupyterlite.readthedocs.io/en/latest/). Try Jupyter was switched to give people a sense of Jupyter offerings, yet not take valuable MyBinder.org resources. They are developing fast and unless you need it and it covers your needs, it is best to keep using normal JupyterLab. I'd suggest you continue to use a full Python-backed JupyterLab on a remote computer in temporary sessions, see [here](https://stackoverflow.com/a/72130198/8508004). – Wayne May 31 '22 at 14:49
  • Also to answer the actual question, how to install things presently is demonstrated by going to [the main JupyterLite page](https://jupyterlite.readthedocs.io/en/latest/) and pressing the orange '`JupyterLab`' button next to '`Try`'. You'll see some examples come up and you can find many more in the '`pyolite`' sub-directory. Current example : `import piplite; await piplite.install(['bqplot', 'ipyleaflet'])`, where the semi-colon represents a new line. Or `await piplite.install("folium")`. piplite is a wrapper to micropip and so you'll see micropip used directly as well in JupyterLite. – Wayne May 31 '22 at 14:58
  • Great, valuable input. Thanks. – Clinical Info Jun 01 '22 at 06:13
  • @Manon's addition today is a good reminder that things have evolved rapidly with JupyterLite, and so the suggestions I give above aren't necessary as there is now the simplified form Manon's answer point's out that makes this easier & more inline with typical JupyterLab and handles the piplite things more behind the scenes. **Also there is a way to use Spyder online without installation on your machine.** Go to [here](https://github.com/spyder-ide/spyder) and choose one of the options. (I believe the top one is the 'stable' one.) – Wayne Apr 03 '23 at 20:25

2 Answers2

1

You probably should install python or use Google Colab instead. Now you are using jupyterLite which is based on Pyodide. Pyodide doesn't support the installation of any python package. but Google Colab uses a real python kernel.

you can install your packages on Colab with:

!pip install some-package-name
Nima Afshar
  • 486
  • 2
  • 7
  • Just to distinguish. Google Colab is a branded branch of Jupyter based on older things as far as I can tell. Modern, vanilla Jupyter in a cell in the notebook, you'd use `%pip install some-package-name` or `%conda install some-package-name`. (And actually because of auto-magics being the default, you can leave off any symbol & get the magic version used usually.) These modern magics were added to avoid the environment issues that can come from using the exclamation point, see [here](https://discourse.jupyter.org/t/why-users-can-install-modules-from-pip-but-not-from-conda/10722/4?u=fomightez). – Wayne May 31 '22 at 14:45
0

Adding to answer 1 since I cannot comment. You don't necessarily have to switch to colab.

You can actually install packages on a Jupyterlite page with %pip install my_package_name in a cell just like in a modern jupyter interface.

This is if you're lucky and either your package and all of its dependencies are pure python, or someone already added your package onto micropip (the equivalent of pip for pyodide packages).

If the package you want to build is not on micropip, then it is a bit harder. You have to make wheels for wasm32 for your specific package. This is documented in pyodide docs here : https://pyodide.org/en/stable/development/new-packages.html

I followed the Rust+python part which was fairly ok, cannot say anything about the other cases but it should be good. One point though, be careful: only python 3.10 works in pyodide at the time I'm writing this (04-2023), I missed it in the docs. So you'll have to build for python 3.10.*.

When you have the wheels, add them in a folder called content at the root of your jupyterlite directory and either run jupyter lite build again or push on your hosted repo if you're using the demonstration template from jupyterlite.

Then you can install it from the jupyterlite notebook with

import micropip
await micropip.install("emfs:" + "path_to_my_wheels.whl") # note that this takes strings and not pathlike objects

The "emfs:" part is because anything in a content folder ends up in the Emscripten file system.

Manon
  • 77
  • 2
  • 9
  • Thanks for updating this. Indeed the use of pip, or actually `piplite` behind-the-scenes, has changed since I first began commenting in this thread. And things have improved a lot in availability of packages in JupyterLite. – Wayne Apr 03 '23 at 20:35