Python UV - 安装、升级、卸载


官方文档详见:https://docs.astral.sh/uv/getting-started/installation/


安装

pip install uv

检查

安装后可运行下面命令,查看是否安装成功

uv --version 

% uv --version
uv 0.6.3 (a0b9f22a2 2025-02-24)

升级

uv self update

将重新运行安装程序 并可能修改您的shell配置文件。

要禁用此行为,设置INSTALLER_NO_MODIFY_PATH=1


或:

pip install --upgrade uv

设置自动补全

echo 'eval "$(uv generate-shell-completion bash)"' >> ~/.bashrc
echo 'eval "$(uv generate-shell-completion zsh)"' >> ~/.zshrc

卸载

执行以下两步:

1、清理存储数据(可选):

$ uv cache clean
$ rm -r "$(uv python dir)"
$ rm -r "$(uv tool dir)"

提示:在删除二进制文件之前,您可能想删除 uv 存储的任何数据。


2、删除 uv 和 uvx 二进制文件:
macOS 和 Linux

$ rm ~/.local/bin/uv ~/.local/bin/uvx

Windows

$ rm $HOME.local\bin\uv.exe
$ rm $HOME.local\bin\uvx.exe

注意:在0.5.0之前,uv被安装到了~/.cargo/bin。可以从那里删除这些二进制文件。
uninstall. 升级到旧版本将不会自动删除二进制文件 ~/.cargo/bin.


UV 命令

 % uv
An extremely fast Python package manager.

Usage: uv [OPTIONS] <COMMAND>

Commands:
  run      Run a command or script
  init     Create a new project
  add      Add dependencies to the project
  remove   Remove dependencies from the project
  sync     Update the project's environment
  lock     Update the project's lockfile
  export   Export the project's lockfile to an alternate format
  tree     Display the project's dependency tree
  tool     Run and install commands provided by Python packages
  python   Manage Python versions and installations
  pip      Manage Python packages with a pip-compatible interface
  venv     Create a virtual environment
  build    Build Python packages into source distributions and wheels
  publish  Upload distributions to an index
  cache    Manage uv's cache
  self     Manage the uv executable
  version  Display uv's version
  help     Display documentation for a command

Cache options:
  -n, --no-cache               Avoid reading from or writing to the cache,
                               instead using a temporary directory for the
                               duration of the operation [env: UV_NO_CACHE=]
      --cache-dir <CACHE_DIR>  Path to the cache directory [env: UV_CACHE_DIR=]

Python options:
      --python-preference <PYTHON_PREFERENCE>
          Whether to prefer uv-managed or system Python installations [env:
          UV_PYTHON_PREFERENCE=] [possible values: only-managed, managed,
          system, only-system]
      --no-python-downloads
          Disable automatic downloads of Python. [env:
          "UV_PYTHON_DOWNLOADS=never"]

Global options:
  -q, --quiet
          Do not print any output
  -v, --verbose...
          Use verbose output
      --color <COLOR_CHOICE>
          Control the use of color in output [possible values: auto, always,
          never]
      --native-tls
          Whether to load TLS certificates from the platform's native
          certificate store [env: UV_NATIVE_TLS=]
      --offline
          Disable network access [env: UV_OFFLINE=]
      --allow-insecure-host <ALLOW_INSECURE_HOST>
          Allow insecure connections to a host [env: UV_INSECURE_HOST=]
      --no-progress
          Hide all progress outputs [env: UV_NO_PROGRESS=]
      --directory <DIRECTORY>
          Change to the given directory prior to running the command
      --project <PROJECT>
          Run the command within the given project directory
      --config-file <CONFIG_FILE>
          The path to a `uv.toml` file to use for configuration [env:
          UV_CONFIG_FILE=]
      --no-config
          Avoid discovering configuration files (`pyproject.toml`, `uv.toml`)
          [env: UV_NO_CONFIG=]
  -h, --help
          Display the concise help for this command
  -V, --version
          Display the uv version

Use `uv help` for more details.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值