Python Reference

Kip Landergren

(Updated: )

Contents

uv

Selected Commands

Projects

uv init create a new python project
uv add add dependency to project
uv remove remove dependency from project

Python Versions

uv python install install python versions
uv python list view available python versions

Resources

pip

Note: prefer using uv.

Selected Commands

pip install install packages
pip freeze output installed packages in requirements format

Selected Options

-U --upgrade Upgrade all specified packages to the newest available version. The handling of dependencies depends on the upgrade-strategy used. (environment variable: PIP_UPGRADE)

Official

venv Virtual Environment

Note: prefer using uv.

Create:

python3 -m venv .venv

Rebuild:

rm -rf ./.venv
python3 -m venv .venv

Activate:

source ./.venv/bin/activate

Deactivate:

deactivate

Resources

Frequently Asked Questions (FAQs)

Why is pip not found in my (.venv) environment?

Iirc venv maintains symlinks, and it may be that the system python interpreter was moved or updated. Exit and regenerate the virtual environment:

deactivate
rm -rf ./.venv
python3 -m venv .venv