Quick Reference

Python and use of virtual environments

During the course of the hackathons you might need Python tools or develop your own application. For security reasons and to leave your system libraries unaffected, we always recommend you develop your demo apps inside a Python virtual environment, as it often wants to install libraries and execute code. Given below are some pointers on how to do that.

The following commands show how to initialize a virtual environment named .venv, install packages to it and run executables from it.

uv init
uv add <package>
uv run <executable>

The <executable> can be python or even something provided by a package such as gradio.

Python scripts

A new way (PEP 723) of developing scripts without having to ensure dependencies is to add inline-script metadata which looks like this:

# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "pandas",
#   "seaborn",
# ]
# ///

import pandas as pd
import seaborn as sns

...

No virtual environments are needed for such scripts to work. This can be executed using uv run command and pipx.