{"schemaVersion":"1.0","type":"TechArticle","types":["Article","TechArticle"],"slug":"replace-pip-venv-and-pyenv-with-uv-one-tool-for-installs-environments-and-python-versions-smq73","url":"https://zyvop.com/replace-pip-venv-and-pyenv-with-uv-one-tool-for-installs-environments-and-python-versions-smq73","title":"Replace pip, venv and pyenv with uv: One Tool for Installs, Environments and Python Versions","subtitle":"A practical guide to switching to uv: install Python versions, manage projects and lockfiles, run scripts and tools, and migrate an existing requirements.txt.","tldr":"pip, venv and pyenv each do one job, and you juggle all three. uv does all of them, plus lockfiles and tools, in one fast binary. Here is how to switch, which commands replace which, and the gotchas to know first.","keywords":["uv","Virtual Environments","tooling","Python","Packaging","DevOps"],"entities":["Pradeep Kumar","uv","Virtual Environments","tooling","Python","Packaging","DevOps","ZyVOP"],"keyTakeaways":["Setting up a Python project usually means three tools.","pyenv picks the interpreter.","venv creates the isolated environment."],"headings":["The old way and the uv way","Install uv","Python versions, without pyenv","Projects: the venv, pip and lockfile in one","The lockfile","Scripts and tools","Migrating an existing project","Where uv pip differs from pip","Gotchas","Five commands to remember"],"outboundLinks":[],"contentText":"Setting up a Python project usually means three tools. pyenv picks the interpreter. venv creates the isolated environment. pip installs the packages. Add pip-tools or Poetry for lockfiles and pipx for command-line tools, and you're juggling five. uv replaces all of them with one program. It's written in Rust, and its README says it's 10 to 100 times faster than pip. I haven't benchmarked that claim, but the bigger win is simpler: one tool, one set of commands. Versions: uv is still pre-1.0 and ships breaking changes in minor releases. The latest release at the time of writing was 0.13.9, from 17 November 2026. The examples were run on uv 0.11.32, and where 0.12 and 0.13 changed a default, the post says so. The old way and the uv way Job Before With uv Install a Python version pyenv install 3.13 uv python install 3.13 Pin a project's Python pyenv local 3.13 uv python pin 3.13 Create an environment python -m venv .venv uv venv, or let uv do it Add a dependency pip install requests uv add requests Install a requirements file pip install -r requirements.txt uv pip install -r requirements.txt Lock dependencies pip-compile uv lock Run in the environment source .venv/bin/activate, then python app.py uv run app.py Run a one-off tool pipx run ruff uvx ruff Install a tool pipx install ruff uv tool install ruff Install uv The standalone installer works on macOS and Linux. Read the script first if you prefer: curl -LsSf https://astral.sh/uv/install.sh | less # inspect it curl -LsSf https://astral.sh/uv/install.sh | sh # install itOther options are pip install uv, brew install uv and winget install --id=astral-sh.uv -e. Heads up: uv self update only works if you used the standalone installer. If you installed another way, upgrade with that tool, for example pip install --upgrade uv. Python versions, without pyenv uv python install 3.13 # download and install uv python list # see what's available and installed uv python pin 3.13 # write .python-version for this project uv python upgrade # move managed versions to the latest patch releaseuv doesn't compile Python. It downloads prebuilt builds from Astral's python-build-standalone project and stores them under its own data directory. It also puts a versioned executable like python3.13 in ~/.local/bin. The experimental --default flag adds plain python and python3 too. You often don't need to run uv python install at all. Commands like uv venv and uv run download a Python automatically when they can't find one. Set UV_PYTHON_DOWNLOADS=never if you'd rather control that. Two things differ from pyenv: The choice is per project. uv looks at the project's .python-version and requires-python, so it doesn't swap your whole shell's python for you. The list of versions is frozen per release. To get a brand-new Python, you may need to upgrade uv first. Heads up: since uv 0.13, a bare uv python install installs Python 3.15, because that became the default stable version. Name the version you want, and use uv python pin so every command in the project agrees. Projects: the venv, pip and lockfile in one uv init myapp cd myapp uv add requests uv run myappuv init creates this: myapp/ ├── .git/ ├── .gitignore ├── .python-version ├── README.md ├── pyproject.toml └── src/ └── myapp/ └── __init__.pyThe key parts of the generated pyproject.toml are a console script and a build system: [project.scripts] myapp = \"myapp:main\" [build-system] requires = [\"uv_build&gt;=…,&lt;…\"] # bounds match your uv version build-backend = \"uv_build\"Heads up: this packaged layout became the default in uv 0.12. Older versions created a single main.py and no build system. Pass --no-package to get that simpler layout. When you upgrade uv, you may also need to loosen the upper bound on uv_build, as the release notes explain. The first uv run or uv add creates two more things: .venv/, the project's virtual environment. uv adds it to .gitignore for you. uv.lock, the exact resolved versions of every dependency. You never activate the environment. uv run handles it, and it keeps everything in sync first: flowchart TD A[\"uv run command\"] --&gt; B{\"Environment exists?\"} B -- No --&gt; C[\"Create .venv with the pinned Python\"] B -- Yes --&gt; D{\"uv.lock matches pyproject.toml?\"} C --&gt; D D -- No --&gt; E[\"Re-lock the dependencies\"] D -- Yes --&gt; F[\"Sync the environment\"] E --&gt; F F --&gt; G[\"Run your command\"]The lockfile uv.lock is a cross-platform file that records exact versions for every operating system, architecture and Python version. Commit it. Don't edit it by hand. A few commands cover day-to-day use: uv add --dev pytest # add to the dev dependency group uv remove requests # remove a dependency uv lock --upgrade-package requests # upgrade one package, keep the rest uv sync --locked # install exactly the lockfile, or fail uv sync --no-dev # leave the dev group out uv export --no-hashes # print a requirements.txt-style listIn CI and Docker, use uv sync --locked. If someone changed pyproject.toml without updating the lockfile, the command stops with an error telling you to run uv lock, which is exactly what you want from a build. Heads up: don't run uv pip install inside a project's environment. The docs recommend uv add for anything that belongs to the project, so the lockfile and pyproject.toml stay in agreement. Scripts and tools Single-file scripts can declare their own dependencies in a comment block, a standard called PEP 723. uv writes the block for you, reads it when you run the script, and builds a throwaway environment: uv init --script report.py --python 3.12 uv add --script report.py requests uv run report.pyAfter those commands, the top of report.py looks like this, and you write the rest: # /// script # requires-python = \"&gt;=3.12\" # dependencies = [ # \"requests\", # ] # /// import requests print(requests.get(\"https://example.com\").status_code)The script's dependencies stay out of your project's environment, so nothing leaks between them. Command-line tools work like pipx: uvx ruff check . # run once in a temporary environment uv tool install ruff # install it for good uv tool list # see what's installeduvx is shorthand for uv tool run. Migrating an existing project You can move in two steps, and you can stop after the first. Step 1: swap pip for uv pip. Nothing else changes: uv venv uv pip install -r requirements.txtIf you use pip-tools, the same idea applies: uv pip compile requirements.in -o requirements.txt uv pip sync requirements.txtStep 2: move to a uv project. Import the requirements, then retire the file: uv init --no-package uv add -r requirements.txt--no-package keeps it a plain application without a build system, which suits most existing apps. uv add -r then copies each requirement into pyproject.toml and creates the lockfile. Once you've committed pyproject.toml and uv.lock, you can delete requirements.txt. If a tool still needs one, uv export generates it. Where uv pip differs from pip uv pip is a drop-in replacement for common pip workflows, but the docs are upfront that it isn't an exact clone. These differences matter most: Virtual environments by default. pip installs globally when no environment is active. uv installs into the active environment, or into a .venv it finds in the current directory or a parent. With neither, it stops and asks you to create one. Pass --system or --python to opt in to anything else. Different config. uv doesn't read pip.conf or PIP_INDEX_URL. Use UV_INDEX_URL, a uv.toml file, or a [tool.uv.pip] section instead. Multiple indexes. uv searches indexes in order and takes versions only from the first index that has the package, which protects against dependency-confusion attacks. pip considers all indexes at once. Pre-releases. Since uv 0.12, it prefers stable versions and only falls back to pre-releases when it must. Gotchas Pin uv in CI. Because it's pre-1.0, a new minor version can change behavior. Pin the version and read the changelog before you bump it. Corporate networks. If TLS certificate errors appear behind a proxy, try UV_SYSTEM_CERTS=true to use the operating system's certificate store. Docker. uv publishes an image at ghcr.io/astral-sh/uv. Old habits. python -m venv and pip still work. You can adopt uv one project at a time. Five commands to remember uv python install 3.13 gets you an interpreter. uv init starts a project. uv add adds a dependency. uv run runs anything inside the project environment. uv sync --locked installs exactly what the lockfile says. Pick one small project, run uv init and uv add -r requirements.txt, and see how it feels. The old tools will still be there if you need them.","contentHash":"sha256:26743afd1398e790855d19a22aa42fb1274f61094ad0711338f3f12976f5ea83","authorName":"Pradeep Kumar","authorUrl":"https://zyvop.com/author/pradeep","authorSameAs":[],"category":"DevOps","tags":["uv","Virtual Environments","tooling","Python","Packaging"],"audience":"Software engineers and developers building applications with DevOps","tone":"Practical and evidence-based engineering guidance","readingTimeMinutes":6,"wordCount":1451,"faqs":null,"primaryTopic":"DevOps","publishedAt":"2026-11-24T06:17:23.430Z","updatedAt":"2026-11-24T06:17:23.430Z","canonicalUrl":"https://zyvop.com/replace-pip-venv-and-pyenv-with-uv-one-tool-for-installs-environments-and-python-versions-smq73"}