Trying out Python packages with ipython and uvx
I figured out a really simple pattern for experimenting with new Python packages today:
uvx --with llm --with sqlite-utils ipythonThis 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:
uvx --python 3.13 --with llm --with sqlite-utils ipythonI turned this into a shell script (with help from Claude):
#!/bin/sh# itry - A portable script for launching ipython with uvx packages
# Show help if requested[ "$1" = "--help" ] && { echo "Usage: itry [packages...]" echo "Example: itry llm sqlite-utils datasette" exit 0}
# Initialize empty string for packagesPACKAGES=""
# Process all arguments, adding --with before eachfor arg in "$@"; do PACKAGES="$PACKAGES --with $arg"done
# Remove leading space if presentPACKAGES="${PACKAGES# }"
# Execute uvx command with Python 3.13exec uvx $PACKAGES --python 3.13 ipythonThis 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:
itry cowsayThen:
import cowsaycowsay.cow("hello") _____| hello | ===== \ \ ^__^ (oo)\_______ (__)\ )\/\ ||----w | || ||