Trying out Python packages with ipython and uvx#
I figured out a really simple pattern for experimenting with new Python packages today:
1uvx --with llm --with sqlite-utils ipython
This command will work if you have uv installed and nothing else. It uses uvx to install and run the excellent ipython Python REPL in a new, dedicated virtual environment with two additional Python libraries - llm and sqlite-utils. You don’t need to install ANY of those packages first - uvx
will fetch and cache them the first time you run this, and reuse the cached versions on future invocations.
You can also set which Python version will be used with the --python 3.13
option:
1uvx --python 3.13 --with llm --with sqlite-utils ipython
I turned this into a shell script (with help from Claude):
1#!/bin/sh2# itry - A portable script for launching ipython with uvx packages3
4# Show help if requested5[ "$1" = "--help" ] && {6 echo "Usage: itry [packages...]"7 echo "Example: itry llm sqlite-utils datasette"8 exit 09}10
11# Initialize empty string for packages12PACKAGES=""13
14# Process all arguments, adding --with before each15for arg in "$@"; do16 PACKAGES="$PACKAGES --with $arg"17done18
19# Remove leading space if present20PACKAGES="${PACKAGES# }"21
22# Execute uvx command with Python 3.1323exec uvx $PACKAGES --python 3.13 ipython
This is saved as ~/.local/bin/itry
- then chmod 755 ~/.local/bin/itry
- and now I can jump straight into an interactive ipython REPL with any Python packages I like using this command:
1itry cowsay
Then:
1import cowsay2cowsay.cow("hello")
1 _____2| hello |3 =====4 \5 \6 ^__^7 (oo)\_______8 (__)\ )\/\9 ||----w |10 || ||