Installation

Notebook run / script run

As it provides a Jupyter widget, pylifemap is primarily designed to be used in a notebook environment such as Jupyter or VSCode.

But it is also possible to use it in a Python script or in the Python REPL. In this case you can use the save() method to export the widget to an HTML file that can be opened later. You can also use the show() method, ins this case the widget is exported to a temporary file and opened in the user’s browser.

Note

pylifemap visualizations can also be embedded in Quarto documents in HTML format.

Install locally

You can install the package locally (preferably in a virtual environment) with pip.

For the moment only the development version can be installed from Github with the following command:

pip install git+https://github.com/Lifemap-ToL/pylifemap.git

Run in Google Colab

You can try the package (without installing anything) in Google Colab.

The easiest way is by using our introduction notebook directly in Colab: Open In Colab.

Run with Docker

Run in Jupyter

Another way to use the package without having to install it is to use our Docker image.

To use pylifemap in a Jupyter environment, you have to install Docker, open a terminal in the directory containing your data and notebook files, and run:

docker run -it -p 8899:8899 -v $PWD:/local/ ghcr.io/Lifemap-ToL/pylifemap:latest

Open the following URL in your browser: http://127.0.0.1:8899/lab, and you will have access to a Jupyter notebook environment with pylifemap and its dependencies preinstalled.

Run a script

If you just want to run a Python script generating a pylifemap visualization, you can open a terminal in the script directory and run the following command:

docker run -v $PWD:/local/ ghcr.io/Lifemap-ToL/pylifemap:latest myscript.py

In this case, if you use show() in your script the result will not be opened in your browser but will instead be saved in a lifemap.html file in your working directory.