Installing modules in jupyterlab online try online
Question:
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.
Answers:
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
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.
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.
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
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.