Package manager written in Rust combining pip, venv, penv
10-100x faster then pip
Uses pyproject.toml to manage dependencies, .python-version to manage py version, and standard .venv/bin/activate to store venv
First time you run uv run, uv sync, or uv lock, creates venv and uv.lock which has exact dependencies
# Initialized project in current dir with pyprojectuvinit# To migrate from requirements.txtuvadd-rrequirements.txt# To sync environment with listed dependenciesuvsyncuvadd'requests==2.31.0'uvaddruffuvrunruffcheckuvremoverequests
Creating Specific Envs
Groups
Other
Venv
Conda/Mamba
Mamba is a faster drop in replacement for conda (100% faster, takes half the time)
uv add --group dev ruff #Dev dependencies
# Once groups are defined, the --all-groups, --no-default-groups, --group, --only-group, and --no-group options can be used to include or exclude their dependencies.
uv sync --all-groups
uv sync --dev #equivalent to --group dev
uv run -- flask run -p 3000 # runs flask or arbitrary commands
uv run script.py
# Can do many pip commands thought its an implementation not pass through
uv pip install
uv pip freeze:
uvx pycowsay 'hello world!' #runs pip packages like pipx
curl -sSL https://install.python-poetry.org | python3 -
curl -sSL https://install.python-poetry.org | asdf exec python3 - #if you are using asdf to manage python versions to avoid default pythons installed on MacOS
asdf global python 3.11.2 #seems to need global setting to desired version
poetry init #setup in project creating pyproject.toml
#may or may not need to set python version in the setup wizard
poetry env use python #might be needed to set version
cat requirements.txt | xargs poetry add #can then delete requirements.txt
poetry add pendulum #add new package
poetry add pendulum@~3.1.4 #for specific minor(3.1) version
poetry add pendulum@^3.1.4 #for specific major(3) version
poetry install #install all packages
poetry run python your_script.py #run
poetry shell #to enter the shell
poetry update #equivalent to deleting poetry.lock and rerunning