from Hacker News

Switching from Pyenv to Uv

by harryvederci on 3/9/25, 9:23 AM with 231 comments

  • by quickslowdown on 3/12/25, 9:18 PM

    I highly, highly recommend uv. It solves & installs dependencies incredibly fast, and the CLI is very intuitive once you've memorized a couple commands. It handles monorepos well with the "workspaces" concept, it can replace pipx with "uv tool install," handle building & publishing, and the docker image is great, you just add a FROM line to the top and copy the bin from /uv.

    I've used 'em all, pip + virtualenv, conda (and all its variants), Poetry, PDM (my personal favorite before switching to uv). Uv handles everything I need in a way that makes it so I don't have to reach for other tools, or really even think about what uv is doing. It just works, and it works great.

    I even use it for small scripts. You can run "uv init --script <script_name.py>" and then "uv add package1 package2 package3 --script <script_name.py>". This adds an oddly formatted comment to the top of the script and instructs uv which packages to install when you run it. The first time you run "uv run <script_name.py>," uv installs everything you need and executes the script. Subsequent executions use the cached dependencies so it starts immediately.

    If you're going to ask me to pitch you on why it's better than your current preference, I'm not going to do that. Uv is very easy to install & test, I really recommend giving it a try on your next script or pet project!

  • by IshKebab on 3/12/25, 10:17 PM

    Uv really fixes Python. It takes it from "oh god I have to fight Python again" to "wow it was actually fast and easy".

    I think all the other projects (pyenv, poetry, pip, etc.) should voluntarily retire for the good of Python. If everyone moved to Uv right now, Python would be in a far better place. I'm serious. (It's not going to happen though because the Python community has no taste.)

    The only very minor issue I've had is once or twice the package cache invalidation hasn't worked correctly and `uv pip install` installed an outdated package until I `uv clean`ed. Not a big deal though considering it solves so many Python clusterfucks.

  • by kubav027 on 3/12/25, 10:07 PM

    I am pretty happy with poetry for near future. I prefer using python interpreters installed by linux package manager. In cloud I use python docker. Poetry recently added option to install python too if I changed my mind.

    I have already setup CI/CD pipelines for programs and python libraries. Using uv would probably save some time on dependency updates but it would require changing my workflow and CI/CD. I do not think it is worth the time right now.

    But if you use older environments without proper lock file I would recommend switching immediately. Poetry v2 supports pyproject.toml close to format used by uv so I can switch anytime when it would look more appealing.

    Another thing to consider in long term is how astral tooling would change when they will need to make money.

  • by kylecordes on 3/12/25, 11:01 PM

    UV is such a big improvement that it moves Python from my "would use again if I had to, but would really not look forward to it" pile to my "happy to use this as needed" pile. Without disparaging the hard work by many that came before, UV shows just how much previous tools left unsolved.
  • by TheIronYuppie on 3/13/25, 12:37 AM

    For scripting... HIGHLY recommend putting your dependencies inline.

    E.g.:

      #!/usr/bin/env python3
      # /// script
      # requires-python = ">=3.11"
      # dependencies = [
      #     "psycopg2-binary",
      #     "pyyaml",
      # ]
      # ///
    
    Then -

      uv run -s file.py
  • by runjake on 3/13/25, 12:48 AM

    For my use cases, uv is so frictionless it has effectively made Python tolerable for me. I primarily discovered it via Simon Willison's (@simonw) blog posts[1]. I recommend his blog highly.

    1. https://simonwillison.net/tags/uv/

  • by vslira on 3/12/25, 9:52 PM

    I'm using exclusively uv for personal projects - and small prototypes at work - and I can't recommend it enough.

    Uv makes python go from "batteries included" to "attached to a nuclear reactor"

  • by selimnairb on 3/13/25, 11:17 AM

    I have been using Python for 20 years, and have been an intermediate to advanced user of it for last 5-7 years. I use it mostly for scientific computing (so lots of Numpy, SciPy, etc.), IoT data processing, and also for some microservices that don’t need to be super fast. I publish and maintain a few packages in PyPI and conda (though I almost never use conda myself), including a C++ library with Python bindings generated by SWIG (SWIG wouldn’t be my first choice, but I inherited it).

    In what I’ve done, I’ve never found things like pipenv, let alone uv, to be necessary. Am I missing something? What would uv get?

  • by mrbonner on 3/12/25, 10:51 PM

    Ans you can now install Python and set it to the default in your path with the --default flag. Big plus for me to replace pyenv finally.
  • by BiteCode_dev on 3/12/25, 10:07 PM

    Note that despite the title, the author is not switching from pyenv to uv, but from pip, pyenv, pipx, pip-tools, and pipdeptree to uv, because uv does much more than pyenv alone.

    It replaces a whole stack, and does each feature better, faster, with fewer modes of failure.

  • by rsyring on 3/12/25, 9:13 PM

    15 year Python dev who usually adopts tooling slowly. Just do it, uv's absolutely worth it.

    I also use mise with it, which is a great combination and gives you automatic venv activation among other things.

    See, among other mise docs related to Python, https://mise.jdx.dev/mise-cookbook/python.html

    See also a Python project template I maintain built on mise + uv: https://github.com/level12/coppy

  • by jillesvangurp on 3/13/25, 8:34 AM

    I dabble with python occasionally and I'm always fighting with tools and tool combinations that don't really combine well. The last time I settled on using conda to get some isolation of python versions and then pipenv for getting some sane package management with a lock file. Not pretty but it kind of worked. Except I had a hard time convincing vs code and pycharm of the correct environment with that combination (couldn't resolve libraries I installed). I got it working eventually but it wasn't a great experience.

    It sounds like uv should replace the combination. Of course there is the risk of this being another case of the python community ritually moving the problem every few years without properly solving it. But it sounds like uv is mostly doing the right thing; which is making global package installation the exception rather than the default. Most stuff you install should be for the project only unless you tell it otherwise.

    Will give this a try next time I need to do some python stuff.

  • by unsnap_biceps on 3/12/25, 8:42 PM

    Uv in script mode has made me love python again.
  • by eikenberry on 3/12/25, 9:28 PM

    Maybe this one will finally be adopted as the official package manager for Python? Only 20 years late, but it would be a nice development.
  • by pzo on 3/13/25, 4:48 AM

    I want to switch to uv from pyenv but one use case that didn't manage to figure out is if I can have similar setup like pyenv that I install few python version and setup one to be a global default (configured in zsh). I know for bigger projects proper way is to setup virtual environment for all new project but I do many mini (throwaway) python scripts and experiments or testing repos in python and would be really annoying to setup environment for those - so far pyenv worked well for me for such cases without having pretty much dependency conflicts.
  • by oblio on 3/12/25, 10:23 PM

    How does this compare to Mise: https://mise.jdx.dev/lang/python.html ?
  • by xenophonf on 3/13/25, 2:45 AM

    What does uv offer over bog-standard setuptools, pip, pip-tools, and build?

    Right now, the only thing I really want is dependency pinning in wheels but not pyproject.yaml, so I can pip install the source and get the latest and greatest, or I can pip install a wheel and get the frozen dependencies I used to build the wheel. Right now, if I want the second case, I have to publish the requirements.txt file and add the wheel to it, which works but is kind of awkward.

  • by tomrod on 3/12/25, 10:45 PM

    I love using it. I'm concerned that they go the route of Terraform and put in play pricing and values that differ from what their users support.
  • by bnycum on 3/12/25, 9:00 PM

    I decided to give uv a shot on my new machine over pyenv and I've been enjoying it. Just last week I had to generate out 90 slides from some data last minute. Quickly created a project added in my dependencies (pandas, matplotlib, python-pptx), then crunched out some code. Absolutely zero friction with a much easier to use set of commands in my opinion.
  • by xucian on 3/9/25, 1:31 PM

    has anybody doing complex projects achiever success with uv completely replacing pyenv, and had mostly pros and few or no cons?

    I'm very comfortable with pyenv, but am extremely open to new stuff

  • by bigfatfrock on 3/13/25, 2:41 AM

    I converted along with most of the people in this thread.

    IMO no really hard problem is ever truly solved but as can be seen in other comments, this group of people really crushed the pain of me and *many* others, so bravo alone on that - you have truly done humanity a service.

  • by aequitas on 3/13/25, 8:48 AM

    I recently switched our Python projects to uv and it love it. It just does everything and is really fast (this just cannot be underestimated in what it means for your workflow).

    I've tried almost every Python packaging solution under the sun in the past 15 years but they all had their problems. Finally I just stuck with pip/pip-tools and plain venv's but strung together with a complicated Makefile to optimize the entire workflow for iteration speed (rebuilding .txt files when .in requirements changes, rebuilding venv if requirements change, etc). I've been able to reduce it to basically one Make target calling uv to do it all.

  • by ashvardanian on 3/12/25, 10:38 PM

    I’m enjoying UV a lot as well. If anyone from the Astral team sees this, I’d love to request more functionality or examples around packaging native libraries.

    At this point, just thinking about updating CIBuildWheel images triggers PTSD—the GitHub CI pipelines become unbearably slow, even for raw CPython bindings that don’t require LibC or PyBind11. It’s especially frustrating because Python is arguably the ultimate glue language for native libraries. If Astral’s tooling could streamline this part of the workflow, I think we’d see a significant boost in the pace of both development & adoption for native and hardware-accelerated tools.

  • by surfingdino on 3/13/25, 12:00 AM

    So... I am switching a project from pip to uv. I am hoping for things to be "better", but so far it's been a bit of a familiar "why does it not work as described?" journey.
  • by globular-toast on 3/13/25, 8:00 AM

    I've stuck with simple tools for all these years: pip, pip-tools, virtualenvwrapper etc. I've tried other stuff like poetry and it's always seemed like hard work. I'm glad I waited for uv. The one thing I wish it supported is having venvs outside of project directories. It's so much nicer to have them all in one place (like ~/.venvs or something) which you can ignore for backups etc. That's the only thing I miss, though.
  • by zahlman on 3/13/25, 3:28 AM

    > Maybe I installed some other things for some reason lost in the sands of time.

    FWIW, I was able to confirm that the listed primary dependencies account for everything in the `pip freeze` list. (Initially, `userpath` and `pyrsistent` were missing, but they appeared after pinning back the versions of other dependencies. The only project for which I couldn't get a wheel was `python-hglib`, which turned out to be pure Python with a relatively straightforward `setup.py`.)

  • by mafro on 3/13/25, 10:24 AM

    I switched to hatch last year for many projects, its been quite pleasant.

    Has anyone used both hatch and uv, and could comment on that comparison?

    EDIT: quick google gives me these opinions[1]

    [1]: https://www.reddit.com/r/Python/comments/1gaz3tm/hatch_or_uv...

  • by jgalt212 on 3/12/25, 11:50 PM

    Because pyenv compiles from source, it's optimized for your own platform. In practice, are these performance differences noticeable?
  • by lmeyerov on 3/12/25, 11:33 PM

    Are people seeing it work well in GPU/pydata land and creating multiplatform docker images?

    In the data science world, conda/mamba was needed because of this kind of thing, but a lot of room for improvement. We basically want lockfile, incremental+fast builds, and multi-arch for these tricky deps.

  • by theogravity on 3/12/25, 8:32 PM

    Is there a guide for how to use uv if you're a JS dev coming from pnpm?

    I just want to create a monorepo with python that's purely for making libraries (no server / apps).

    And is it normal to have a venv for each library package you're building in a uv monorepo?

  • by o10449366 on 3/12/25, 11:58 PM

    If uv figures out a way to capture the scientific community by adding support for conda-forge that'll be the killshot for other similar projects, imo. Pixi is too half-baked currently and suffers from some questionable design decisions.
  • by OutOfHere on 3/12/25, 10:23 PM

    The functionalities of three tooling projects, namely uv, ruff (linter), and pyright (type checker) need to merge and become mandatory for new Python projects. Together they will bring some limited sanity to Python.
  • by 77ko on 3/13/25, 2:54 AM

    uv is excellent! The only think I'm missing is an easy way to update all packages in an env, something like `uv update --all` or `uv update plotly`.

    Which would fit in with existing uv commands[1] like `uv add plotly`.

    There is an exisiting `uv lock --upgrade-package requests` but this feels a bit verbose.

    [1]: https://docs.astral.sh/uv/guides/projects/#creating-a-new-pr...

  • by randomsolutions on 3/13/25, 12:37 PM

    My biggest issue is using uv envs in vscode under WSL. Starting up interactive sessions takes forever. Its just too slow, can't figure out what the deal is.
  • by stuaxo on 3/13/25, 1:16 AM

    This makes sense for people keen on pyenv.

    I'm still very keen on virtualenvwrapper, I hope that the fast dependency resolution and install of uv can come there and to poetry.

  • by BewareTheYiga on 3/14/25, 12:58 AM

    I can't say enough good things about UV. It has simplified and accelerated my python and Jupyter projects. I even run it in my pipelines.
  • by moltar on 3/12/25, 10:11 PM

    I wasn’t able to figure how to make a uv installed python version a global when “python” is called, at least in the current shell, as I need it in CI.
  • by whimsicalism on 3/13/25, 3:36 AM

    frankly the only pain point i have working with uv is that it's too new for the LLMs to know about it
  • by mrlatinos on 3/13/25, 3:38 AM

    Here we go again.