uv
uv copied to clipboard
Add `uv pip list`
This is a really helpful command :)
Yes please! :)
Wow I'm so used to pip freeze
, no idea why!
Is it important we follow the exact same format? Do people read this programmatically?
Maybe this can help? https://github.com/pypa/pip/pull/752
Is it important we follow the exact same format? Do people read this programmatically?
Hm, good question. Problably not required to have the exact same output, but I think plenty of people are doing grep
/awk
/sed
stuff on the output of pip list
(I know I am).
@charliermarsh as to why pip list
when pip freeze
exists, I would say the spacing choices are more (quickly) human readable and having the two column structure allows for parsing of package (not version) easier.
$ docker run --rm -ti python:3.12 /bin/bash
root@4106918bf8c2:/# python -m venv venv && . venv/bin/activate
(venv) root@4106918bf8c2:/# python -m pip --quiet install awkward
(venv) root@4106918bf8c2:/# python -m pip list
Package Version
----------- --------
awkward 2.6.1
awkward-cpp 29
fsspec 2024.2.0
numpy 1.26.4
packaging 23.2
pip 24.0
(venv) root@4106918bf8c2:/# python -m pip freeze
awkward==2.6.1
awkward-cpp==29
fsspec==2024.2.0
numpy==1.26.4
packaging==23.2
(venv) root@4106918bf8c2:/#
For me, pip list
is the goto and as an example of how I use it also programatically, here's how I clean up my virtual environment so that I can have clean installs when I'm updaing my GPU support enabled JAX environment
#!/bin/bash
python -m pip list | grep 'jax\|nvidia\|ml-dtypes' | awk '{print $1}' | xargs python -m pip uninstall --yes
python -m pip list
JAX_VERSION=0.4.24
# CUDA_VERSION=11
CUDA_VERSION=12
CUDA_DISTRIBUTION="pip"
# CUDA_DISTRIBUTION="local"
python -m pip install --upgrade "jax[cuda${CUDA_VERSION}_${CUDA_DISTRIBUTION}]==${JAX_VERSION}" --find-links https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
python -m pip list | grep jax
echo ""
python jax_detect_GPU.py
Funny, I didn't know we had a freeze
command 😶🌫️
pip list --outdated
is also a useful feature.
pip list also shows editable install locations (if any) as compared to pip freeze.
There is also the --format
option you might want to support.
--format <list_format> Select the output format among: columns (default), freeze, or json. The 'freeze' format cannot be used with the --outdated option.
Then you could do uv pip list --format=freeze
. The json
format could be good for people who read this programmatically.
Is --format=freeze
different than pip freeze
?
This was added in https://github.com/astral-sh/uv/pull/1662 so I'm going to close this now. We can track output formats in a new issue.
Is
--format=freeze
different thanpip freeze
?
(uvtest) C:\Users\User\Desktop\uvtest> python -m pip list --format freeze
pip==24.0
setuptools==68.0.0
uvtest==0.1.0
wheel==0.42.0
(uvtest) C:\Users\User\Desktop\uvtest> python -m pip freeze
# Editable Git install with no remote (uvtest==0.1.0)
-e c:\users\user\desktop\uvtest
Yes, they are different, but I'd like to pip list --format freeze
supersede pip freeze
. tracked in #1970.