r/learnpython • u/GarlicHefty • Oct 13 '26
What is the best way to create and manage virtual environments today? Is 'uv' really the best?
What is the best way to create and manage virtual environments today? Is 'uv' really the best solution and are there alternative? What are the pros and cons?
18
Upvotes
12
u/flyby_apis Oct 13 '26
I'm using venv+pip as I'm used to requirements.txt, but uv it's faster and a good replacement
4
u/this_knee Oct 13 '26
I’ve never been a fan of virtual environments within a language itself. So I typically just skip it and run my Python code in its own docker container. Easier for me.
6
u/a18618 Oct 14 '26
I sat on plain venv for years and only switched to uv a few months ago. What won me over wasn't venv creation speed, it was dependency resolution on big scientific stacks — a pandas/numpy/scipy solve that took pip over a minute finished in seconds with uv. uv run also killed the whole "did I activate the right venv" dance for me. venv is still fine, but once I stopped fighting the activation step I never looked back.
2
u/JamzTyson Oct 16 '26
There really isn't a "best" tool for managing virtual environments. I usually use
Poetryto manage virtual environments because I also use it to manage packages and publishing. Similarly, if you are usinguvto manage the project dependencies, then it makes sense to useuvto manage the virtual environment. For small projects,venv(withpipto manage dependencies) is easy and is included in Python.3
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 Oct 13 '26
For what it's worth, I find it difficult to imagine a situation where
uvwould be actively worse than other options. It's really well optimised, caching is well thought-out, manages both your dependencies and Python installations, and it has good availability both platform-wise and between local and CI environments.At this point the only thing I'd like it to have is dependency license auditing, so I could stop using
pip-licensesat work.Combined with Mise (to lock down
uvversion for reproducible builds) and Taskfile (to make actions like installing the project and running tests easier to unify between local and CI environments) I've been extremely satisfied. For example, my recently updated template project for Rust/Python mixed projects now lets me install everything (from tooling to dependencies and Git hooks) with justmise install && task install.4
u/BranchLatter4294 Oct 13 '26
Venv works fine for me. I know uv is faster, but I don't spend a huge amount of time managing environments anyway.
1
u/TheBlackCat13 Oct 13 '26
I have tried a few approaches and it works great for me. The big advantage is automatically pulling in the correct version of python, which helps when working across multiple machines or with other people.
1
u/jmacey Oct 13 '26
I use uv for everyting, I often combine it with https://direnv.net/ so I can auto activate the ven and set other functions up in zsh for ease.
Works really well for me.
1
u/preppie22 Oct 13 '26
uv for projects with pyproject.toml and frozen package versions. pyenv for reusable environments for specific purposes.
1
u/InTheAleutians Oct 13 '26
I'm always needing to update my python installations to the current security patch. Having uv update python then just entering a project and typing uv sync to update the venv is so smooth.
1
u/Financial_Morning386 Oct 14 '26
uv is the best default I would pick for a new Python project today, but not because venv+pip is broken — because it collapses three separate problems into one workflow.
Trade-offs / when not to use it:
Practical starting point: `uv init my-service`, commit both `pyproject.toml` and `uv.lock`, and document `uv sync` as the setup step. That covers most backend/API projects without the extra complexity of Poetry + pyenv + pip-tools combined.
1
u/AbundantSpaghetti Oct 14 '26
I migrated from global installs, to pip + venv, to poetry, to uv.
uv is the best of the lot.
1
u/BleedReddit Oct 14 '26
I use
pyenvto manage Python versions andvenvto create a separate virtual environment for each project. I keep my Python installation on an external drive and tend to usepyproject.tomlfor project configuration. I haven't switched touvyet, so I'm sticking with the setup that works for me for now.1
u/Massive_Distance_616 Oct 17 '26
“Best” depends on what you’re optimising for. Here is how the main options actually differ.
venv + pip ships with Python, zero new tools to learn, works fine for simple projects. The friction points are manual dependency pinning, a slow resolver on complex stacks, and the activation dance (
source .venv/bin/activatein every new shell).uv written in Rust, so dependency resolution is dramatically faster on large or conflicting stacks. It also manages Python installations directly (replaces pyenv), maintains a proper lockfile (
uv.lock), and can build and publish packages withuv build/uv publish. Theuv runcommand runs things in the correct environment without manual activation but it’s optional. uv creates a standard.venvthat you can still activate and use normally if you prefer.Poetry mature ecosystem, clean dependency groups, solid lockfile. Worth considering if your team already has Poetry CI templates or plugins, but for new projects uv covers most of what made Poetry compelling.
conda the right call when your environment has non-Python system-level dependencies: CUDA runtimes, BLAS, compiled C libraries. conda manages those at the environment level in a way pip doesn’t. Modern conda has the libmamba solver enabled by default, so it’s much faster than it used to be. Overkill if you’re working with pure Python packages.
Docker not a venv replacement, a level up. Containerises your entire runtime (Python version, system deps, config). Use it for deployment and CI consistency; use a venv tool for day-to-day development.
For a new project today: uv. Reach for conda only if you hit compiled non-Python dependencies, and Docker when you’re shipping to production.
1
u/driftwood14 Oct 13 '26
I was never a big fan of venv so I always used conda. But yesterday I tried uv for the first time and I found it really nice to use.
1
u/brasticstack Oct 13 '26
I tried
uvfor the first time on a new project, and it's not for me. I've never found it all that hard to activate a virtualenv manually (like is everyone else from those infomercials where a person wrecks their whole kitchen trying to open a jar of jam?). The thing I most dislike is that I now have touv run xyzinstead of justxyzfor everything in the venv.0
u/nizzoball Oct 14 '26
I’ve always used venv and only prefer it because it’s what I’ve always used. Best is subjective as with anything. Theres really no quantifiable way of defining what is best