Skip to content
uv-management logo

UV Management

uv-management

Quick reference for uv (fast Python package manager) operations to save tokens. Use when creating virtual environments, installing packages, managing dependencies, or when user asks about uv commands. Provides concise patterns for Python project setup and package management.

mattnigh/skills_collection0installs24stars

SKILL.md

Full skill instructions

UV Management

Quick reference for uv - the fast Python package installer and environment manager.

Installation

Install UV

# macOS/​Linux
curl -LsSf https://astral.sh/​uv/​install.sh | sh

# Or with pip
pip install uv

# Verify installation
uv --version

Project Initialization

Create New Project

# Initialize new project
uv init project-name

# Initialize in current directory
uv init

# With specific Python version
uv init --python 3.11

Project Structure Created

project-name/
├── pyproject.toml    # Project configuration
├── .python-version   # Python version specification
└── src/
    └── project_name/
        └── __init__.py

Virtual Environment

Create Virtual Environment

# Create venv (automatic with uv)
uv venv

# With specific Python version
uv venv --python 3.11

# With custom name
uv venv .venv-custom

# Activate (same as regular venv)
source .venv/​bin/​activate  # macOS/​Linux
.venv\Scripts\activate     # Windows

Python Version Management

# List available Python versions
uv python list

# Install specific Python version
uv python install 3.11

# Pin Python version for project
uv python pin 3.11

Package Management

Install Packages

# Install single package
uv pip install package-name

# Install specific version
uv pip install package-name==1.2.3

# Install from requirements.txt
uv pip install -r requirements.txt

# Install from pyproject.toml
uv pip install -e .

# Install development dependencies
uv pip install -e ".[dev]"

Add Dependencies (Modern Way)

# Add package to project
uv add numpy

# Add with version constraint
uv add "numpy>=1.24,<2.0"

# Add multiple packages
uv add numpy pandas matplotlib

# Add as dev dependency
uv add --dev pytest black ruff

# Add from git
uv add git+https://github.com/​user/​repo.git

Remove Packages

# Remove package
uv remove package-name

# Remove dev dependency
uv remove --dev pytest

Update Packages

# Update single package
uv pip install --upgrade package-name

# Update all packages
uv pip install --upgrade -r requirements.txt

# Sync dependencies (recommended)
uv sync

Dependency Management

Lock Dependencies

# Generate lock file
uv lock

# Lock and sync
uv lock --sync

Export Requirements

# Export to requirements.txt
uv pip freeze > requirements.txt

# Export from pyproject.toml
uv export --format requirements-txt > requirements.txt

Running Commands

Run Python

# Run Python script
uv run python script.py

# Run module
uv run -m module_name

# Run with arguments
uv run python script.py --arg value

Run Tools

# Run pytest
uv run pytest

# Run black
uv run black .

# Run ruff
uv run ruff check .

# Run any tool
uv run tool-name [args]

VRP Project Setup

Initial Project Setup

# 1. Create project directory
mkdir vrp-toolkit
cd vrp-toolkit

# 2. Initialize with uv
uv init

# 3. Create virtual environment
uv venv

# 4. Activate environment
source .venv/​bin/​activate

# 5. Install core dependencies
uv add numpy pandas matplotlib networkx

# 6. Install dev dependencies
uv add --dev pytest black ruff ipython jupyter

# 7. Install OSMnx (for real map support)
uv add osmnx geopandas

# 8. Install package in editable mode
uv pip install -e .

pyproject.toml for VRP Toolkit

[project]
name = "vrp-toolkit"
version = "0.1.0"
description = "Reusable VRP/​PDPTW solving framework"
requires-python = ">=3.8"
dependencies = [
    "numpy>=1.24.0",
    "pandas>=2.0.0",
    "matplotlib>=3.7.0",
    "networkx>=3.0",
]

[project.optional-dependencies]
dev = [
    "pytest>=7.0.0",
    "black>=23.0.0",
    "ruff>=0.1.0",
    "ipython>=8.0.0",
    "jupyter>=1.0.0",
]
osmnx = [
    "osmnx>=1.6.0",
    "geopandas>=0.14.0",
    "folium>=0.15.0",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.ruff]
line-length = 100
target-version = "py38"

[tool.black]
line-length = 100
target-version = ["py38"]

Install All Dependencies

# Install main dependencies
uv add numpy pandas matplotlib networkx

# Install dev tools
uv add --dev pytest black ruff ipython jupyter

# Install OSMnx group
uv add osmnx geopandas folium

# Or install from pyproject.toml
uv sync

Common Workflows

Daily Development

# Activate environment
source .venv/​bin/​activate

# Run tests
uv run pytest

# Format code
uv run black .

# Lint code
uv run ruff check .

# Run Jupyter
uv run jupyter lab

Add New Dependency

# Add package
uv add package-name

# Test it works
uv run python -c "import package_name; print('OK')"

# Commit updated pyproject.toml
git add pyproject.toml uv.lock
git commit -m "chore: add package-name dependency"

Clean Install

# Remove existing environment
rm -rf .venv

# Recreate
uv venv

# Reinstall all dependencies
uv sync

# Verify
uv run python -c "import numpy; print(numpy.__version__)"

Comparison with pip/​venv

TaskTraditionalUV
Create venvpython -m venv .venvuv venv
Activatesource .venv/​bin/​activateSame
Install packagepip install packageuv add package
Install requirementspip install -r requirements.txtuv pip install -r requirements.txt
Freeze depspip freeze > requirements.txtuv pip freeze > requirements.txt
Run toolpython -m pytestuv run pytest

Key Advantages of UV:

  • ⚡ 10-100x faster than pip
  • 🔒 Built-in dependency locking
  • 🐍 Python version management
  • 📦 Cleaner dependency specification in pyproject.toml

Troubleshooting

UV Not Found After Install

# Add to PATH (add to ~/​.zshrc or ~/​.bashrc)
export PATH="$HOME/​.cargo/​bin:$PATH"

# Reload shell
source ~/​.zshrc

Wrong Python Version

# Check current Python
uv run python --version

# List available versions
uv python list

# Install correct version
uv python install 3.11

# Pin to project
uv python pin 3.11

# Recreate venv
rm -rf .venv
uv venv

Dependency Conflicts

# See resolution
uv tree

# Try updating
uv sync --upgrade

# Force reinstall
rm -rf .venv uv.lock
uv venv
uv sync

Package Not Found

# Make sure package name is correct
uv add numpy  # Correct
uv add NumPy  # Wrong (case sensitive)

# Check if package exists
pip search package-name

# Or search on PyPI: https://pypi.org/

Advanced Usage

Multiple Environments

# Create environment with different name
uv venv .venv-dev

# Activate specific environment
source .venv-dev/​bin/​activate

# Install different dependencies
uv add specific-package

Dependency Groups

# Install specific group
uv sync --group dev

# Install multiple groups
uv sync --group dev --group osmnx

# Install all groups
uv sync --all-groups

Build and Publish

# Build package
uv build

# Publish to PyPI (requires twine)
uv run twine upload dist/​*

Integration with Other Skills

Works with:

  • session-start: Check Python environment status
  • migrate-module: Ensure dependencies are installed
  • osmnx-integration: Install OSMnx and geo packages

Example project setup:

# 1. Initialize project
uv init vrp-toolkit
cd vrp-toolkit

# 2. Setup environment
uv venv
source .venv/​bin/​activate

# 3. Install dependencies
uv add numpy pandas matplotlib networkx
uv add --dev pytest black ruff jupyter
uv add osmnx geopandas  # For OSMnx integration

# 4. Install in editable mode
uv pip install -e .

# 5. Verify installation
uv run python -c "from vrp_toolkit import *; print('OK')"

# 6. Start development
uv run jupyter lab

Quick Reference

TaskCommand
Init projectuv init
Create venvuv venv
Add packageuv add package
Add dev depuv add --dev tool
Install alluv sync
Run scriptuv run python script.py
Run tooluv run pytest
Update alluv sync --upgrade
Lock depsuv lock
Export reqsuv pip freeze > requirements.txt
Python versionuv python install 3.11
Pin Pythonuv python pin 3.11

Migration from pip

Convert requirements.txt to pyproject.toml

# 1. Read existing requirements
cat requirements.txt

# 2. Add packages one by one
uv add package1 package2 package3

# Or install and then generate pyproject.toml
uv pip install -r requirements.txt
uv pip freeze  # Review installed packages

Migrate Existing Project

# 1. In existing project directory
cd existing-project

# 2. Create uv environment
uv venv

# 3. Install from requirements.txt
uv pip install -r requirements.txt

# 4. Generate pyproject.toml (manual)
uv init --no-workspace

# 5. Add dependencies to pyproject.toml
uv add $(cat requirements.txt | grep -v '#' | cut -d'=' -f1)

More skills from mattnigh

spring-framework-patterns logo
mattnigh/skills_collection

spring-framework-patterns

Comprehensive Spring Framework and Spring Boot best practices including dependency injection patterns, bean lifecycle and scopes, REST API development, Spring Data JPA, service layer design, Spring Security, testing strategies, caching, AOP, async processing, error handling, and common anti-patte...

24 0
View

TypeScript厳格モードによる型安全性設計を専門とするスキル。 📖 参照書籍: - 『Effective TypeScript』(Dan Vanderkam): 型設計 📚 リソース参照: - `resources/Level1_basics.md`: レベル1の基礎ガイド - `resources/Level2_intermediate.md`: レベル2の実務ガイド - `resources/Level3_advanced.md`: レベル3の応用ガイド - `resources/Level4_expert.md`: レベル4の専門ガイド - `resources/di...

24 0
View
deploying-cloud-k8s logo
mattnigh/skills_collection

deploying-cloud-k8s

Deploys applications to cloud Kubernetes (AKS/GKE/DOKS) with CI/CD pipelines. Use when deploying to production, setting up GitHub Actions, troubleshooting deployments. Covers build-time vs runtime vars, architecture matching, and battle-tested debugging.

24 0
View
moai-alfred-agent-guide logo
mattnigh/skills_collection

moai-alfred-agent-guide

19-agent team structure, decision trees for agent selection, Haiku vs Sonnet model selection, and agent collaboration principles. Use when deciding which sub-agent to invoke, understanding team responsibilities, or learning multi-agent orchestration.

24 0
View
mermaid-diagram-generator logo
mattnigh/skills_collection

mermaid-diagram-generator

Converts architecture descriptions, module specs, or workflow docs into Mermaid diagrams. Use when visualizing brick module relationships, workflows (DDD, investigation), or system architecture. Supports: flowcharts, sequence diagrams, class diagrams, state machines, entity relationship diagrams,...

24 0
View
pre-flight-check logo
mattnigh/skills_collection

pre-flight-check

INVOKE FIRST before any code work. Validates git workflow (branch, issue, worklog) and checks approach. Use at START of every task and END before completing. Prevents skipped steps.

24 0
View
browser-dev-tools logo
mattnigh/skills_collection

browser-dev-tools

This skill should be used when working with browser-rendered artifacts (i.e. Bun, React/React Native) to proactively validate that development work on localhost is being built appropriately and to support debugging browser-rendered content. Use this skill after making frontend changes to verify t...

24 0
View
lead-dev logo
mattnigh/skills_collection

lead-dev

Lead Développeur - Coordination technique opérationnelle, code review, mentoring et livraison. Pair de web-dev-process au niveau OPÉRATIONS.

24 0
View
worker-monitor logo
mattnigh/skills_collection

worker-monitor

Monitor Docker workers, RQ queue health, and auto-scale workers (max 4). Use when: checking job progress, monitoring queue depth, scaling workers up/down, diagnosing slow processing, or waiting for jobs to complete. Referenced by data-quality skill during reprocessing.

24 0
View
quality-advisor logo
mattnigh/skills_collection

quality-advisor

Proactive quality guidance system that monitors artifact creation and provides real-time feedback on documentation quality

24 0
View
bump-version logo
mattnigh/skills_collection

bump-version

This skill should be used when the user wants to bump the version number in the workspace. It updates versions across all pyproject.toml files (root, tde, and tda packages) and the CHANGELOG.md to keep them synchronized.

24 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View