Python UV安装、升级、卸载详细步骤记录

作者:

文章目录
  • 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.localbinuv.exe $ rm $HOME.localbinuvx.exe 注意:在0.5.0之前,uv被安装到了~/.cargo/bin。可以从那里删除这些二进制文件。uninstall. 升级到旧版本将不会自动删除二进制文件 ~/.cargo/bin.
  • % 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.
  • 到此这篇关于Python UV安装、升级、卸载详细步骤的文章就介绍到这了,更多相关Python UV安装升级卸载内容请搜索风君子博客以前的文章或继续浏览下面的相关文章希望大家以后多多支持风君子博客! 您可能感兴趣的文章: 如何使用uv构建Python包并本地安装步骤详解 python uv包管理小结 python uv 基本使用教程 使用uv管理python虚拟环境的流程步骤 Python-UV多环境管理的方法 现代 Python 包管理器 uv的使用详解
  • 目录
    • 安装
    • 检查
    • 升级
    • 设置自动补全
    • 卸载
    • 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.localbinuv.exe
    $ rm $HOME.localbinuvx.exe
    

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

     % 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.

    到此这篇关于Python UV安装、升级、卸载详细步骤的文章就介绍到这了,更多相关Python UV安装升级卸载内容请搜索风君子博客以前的文章或继续浏览下面的相关文章希望大家以后多多支持风君子博客!

    您可能感兴趣的文章:

    • 如何使用uv构建Python包并本地安装步骤详解
    • python uv包管理小结
    • python uv 基本使用教程
    • 使用uv管理python虚拟环境的流程步骤
    • Python-UV多环境管理的方法
    • 现代 Python 包管理器 uv的使用详解

    站内搜索