Package Manager Configuration

image

uv Configuration

uv is the recommended package manager. Most configuration lives in pyproject.toml and uv.lock, but some behaviors can be configured via environment variables.

Global Cache

uv caches downloaded packages by default in ~/.cache/uv/ (macOS/Linux) or %LOCALAPPDATA%\uv\cache (Windows). This means packages are downloaded once and shared across all projects and virtual environments.

To clear the cache:

$ uv cache clean

To set a custom cache directory:

$ export UV_CACHE_DIR=/path/to/cache

Requiring an Active Environment

When using pip directly (not uv), it's easy to accidentally install packages globally. To prevent this, add to your ~/.bashrc or ~/.zshrc:

export PIP_REQUIRE_VIRTUALENV=true

Then pip will refuse to install outside a virtual environment:

$ pip install requests
Could not find an activated virtualenv (required).

Override it when you need a global install:

gpip() {
    PIP_REQUIRE_VIRTUALENV=false pip "$@"
}

pip Configuration

If you use pip alongside uv, you can configure it via pip.conf (macOS/Linux) or pip.ini (Windows):

macOS / Linux: ~/.pip/pip.conf Windows: %USERPROFILE%\pip\pip.ini

Example configuration:

[global]
require-virtualenv = true

Caching with pip

Modern pip (6.0+) has built-in caching enabled by default — no configuration needed. If you're on an older version, upgrade:

$ pip install --upgrade pip

Summary: uv vs pip

Taskuvpip
Install packageuv add requestspip install requests
Install (one-time)uv pip install requestspip install requests
Lock dependenciesAutomatic (uv.lock)Manual (pip freeze > requirements.txt)
Create venvAutomatic or uv venvpython3 -m venv .venv
Run in envuv run <command>Activate venv first
Global toolsuv tool install <pkg>pipx install <pkg>
CacheBuilt-in, fastBuilt-in

Use uv for projects. Use uv pip when you need pip-compatible commands. Use uv tool for global CLI tools.