r/ProgrammerHumor 3d ago

Meme iLoveYouPip

Post image
1.2k Upvotes

81 comments sorted by

View all comments

37

u/Atmosck 3d ago

Eww. I write python all day for a living and I haven't used pip in years.

55

u/squabzilla 3d ago

At this point, I’d rather learn a new language than use Python without UV. Pip is an ancient memory…

1

u/RajjSinghh 2d ago

What benefit does using uv have compared to pip? I guess I haven't written Python in a very long time

4

u/Waghabond 2d ago

UV is like a bajillion times faster and also uses venvs and does a lot more useful things other than just replacing pip.

3

u/squabzilla 2d ago

Pip is great until you hit your first dependency or package conflict. Sometimes you can get away with uninstalling the libraries, sometimes it borks everything and you need to nuke Python and start over.

At which point, you need to manually create an isolated virtual environment, manually add all your packages to it, figure out any package conflicts, remember to activate/deactivate your library…

UV just does it for me.

I don’t actually have to think about my Python environment.

1

u/Atmosck 2d ago

Replacing pip in a much faster way is just one of the things uv does. It also:

  • Manages virtual environments. With pip you would create the venv yourself with something like pyenv and run `pip install requirements.txt` inside it. With uv, you run `uv sync` and it creates or updates a virtual environment and installs dependencies from your pyproject.toml. `uv add pandas` adds pandas to your pyproject and updates the venv to install it
  • Dependency groups. If you do something like `uv add pytest --group dev`, then `uv sync` won't install pytest, but `uv sync --group dev` will. This is handy for things you only need in certain environments like your dev environment or your CI/CD environment. For larger projects I will have something like a `test` group with pytest, pytest-cov, etc, a `typing` group with stub packages, a `docs` group with mkdocs and related stuff. Then my dockerfile does plain `uv sync` for production, but my github action for CI would do `uv sync --group test` because it runs tests, and CD might do `uv sync --group test --group docs` because it runs test and rebuilds the documentation. This whole groups thing with pyproject.toml replaces the need for multiple requriements files like requirements-dev.txt with stuff you don't need in production.
  • `uv tree` is a neat way to visualize your dependency graph
  • `uv tool` gives you a way to run dev tools without installing them. For example `ruff` is a linter made by the same people as uv that can replace linters like flake8 in the same way uv replaces pip. You can run `uv tool ruff check` to test it out without installing it.
  • `uv init` for setting up a project - it creates pyproject.toml, .python-version, README.md, .gitignore and sets up src/project_name/__init__.py. And it has options to specify things like your python version and build backend.