Python - UV
Table of Contents
As another tool for Python, uv is written by rust and provides integrated experience, e.g.
- interpretor management (by
uv python) - virtual environment manangement (by
uv venv) - package management (by
uv pip) - project management (by
uv init/add/lock/sync)
In Archlinux, uv can be easily installed by pacman, i.e.,
pacman -S uv
Its usage can be summarized as follows. Note that, if a virtual environment has already activated, then the argument --python /PATH/TO/ENVIRONMENT below can be omitted.
Python interpretor management
List the interpretors.
uv python listInstall an interpretor.
uv python install x.y[.z]
Virtual environment
Create a virtual environment based on the system interpretor.
uv venv --python /usr/bin/python /PATH/TO/ENVIRONMENTCreate a virtual environment based on a specified interpretor.
uv venv --python x.y[.z] /PATH/TO/ENVIRONMENT
Run a Python script or a function
uv run [--python /PATH/TO/ENVIRONMENT] SCRIPT.py
Package management
List the [outdated] packages installed.
uv pip list [--outdated] [--python /PATH/TO/ENVIRONMENT]List the details of a package.
uv pip show [--python /PATH/TO/ENVIRONMENT] PACKAGE_NAMEInstall a package.
uv pip install [--python /PATH/TO/ENVIRONMENT] PACKAGE_NAMEInstall packages from a list.
uv pip install [--python /PATH/TO/ENVIRONMENT] -r requirements.txtUpgrade a package.
uv pip install [--python /PATH/TO/ENVIRONMENT] --upgrade PACKAGE_NAMEUpdate packages from a list.
uv pip install [--python /PATH/TO/ENVIRONMENT] --upgrade -r requirements.txtRemove a package.
uv pip uninstall [--python /PATH/TO/ENVIRONMENT] PACKAGE_NAMEExport the list of installed packages.
uv pip freeze [--python /PATH/TO/ENVIRONMENT] > requirements.txt
Mirror configuration
A mirror site can be configured in ~/.config/uv/uv.toml or /etc/uv/uv.toml.
[[index]]
url = "https://mirrors.aliyun.com/pypi/simple"
default = true