Skip to content

Difference between uv, uvx and pip

1. Purpose

This post aims to introduce the Python dependency management tools uv, uvx, and pip. I’ll explain their usage and key differences.

2. Environment

  • macos System

3. What is the difference between the uv,uvx and pip?

pip is the most widely used package installer in the Python community, while uv and uvx, developed by Astral, are designed to offer a faster and more reliable alternative. Understanding what sets them apart is key to choosing the right tool for your needs.

Here is the diagram show their differences:

What is pip?

pip is the standard package management system for Python. It’s what you use to install and manage software packages, which are most often found on the Python Package Index (PyPI). pip is a comprehensive tool that supports managing project dependencies via requirements.txt files and is the foundational and most common tool in the Python ecosystem.

pip is the most widely used package installer for Python.

  • Install a package:

    Terminal window
    pip install requests

    This command installs the latest version of the requests library from PyPI.

  • Install a specific version:

    Terminal window
    pip install flask==2.2.2

    This installs version 2.2.2 of the flask library.

  • Install from a requirements.txt file:

    Terminal window
    pip install -r requirements.txt

    This is a very common way to install all dependencies listed in a requirements.txt file.

  • Upgrade a package:

    Terminal window
    pip install --upgrade numpy

    This upgrades the numpy package to the latest available version.

  • Uninstall a package:

    Terminal window
    pip uninstall requests

    This command removes the requests library from your environment. You will typically be prompted to confirm.

  • List installed packages:

    Terminal window
    pip list

    Shows all installed packages and their versions in the current environment.

  • List installed packages in requirements.txt format:

    Terminal window
    pip freeze

    Outputs the list of installed packages and their exact versions in a format suitable for requirements.txt.

What is uv?

uv is a high-performance Python package installer and resolver written in Rust. It’s built to be a drop-in replacement for common pip and pip-tools workflows. uv is laser-focused on speed and reliability, offering features like dependency resolution, locking, installation, and virtual environment management. Its ambitious goal is to become the “Cargo for Python” (Cargo being Rust’s build tool and package manager).

Here are some examples of using uv:

  • Create a virtual environment:

    Terminal window
    uv venv

    This creates a new virtual environment in a .venv directory in your current location.

  • Activate a virtual environment (Linux/macOS):

    Terminal window
    source .venv/bin/activate
  • Activate a virtual environment (Windows):

    Terminal window
    .venv\Scripts\activate
  • Install a package:

    Terminal window
    uv pip install requests

    Similar to pip install, but typically much faster.

  • Install from a requirements.txt file:

    Terminal window
    uv pip install -r requirements.txt

    Installs dependencies from a requirements.txt file using uv’s speed.

  • Compile a requirements.txt file (like pip-compile):

    Terminal window
    uv pip compile requirements.in -o requirements.txt

    Reads dependencies from requirements.in and generates a locked requirements.txt with exact versions.

  • Sync an environment with a locked requirements.txt (like pip-sync):

    Terminal window
    uv pip sync requirements.txt

    Installs or uninstalls packages to match the exact versions in the requirements.txt file.

  • Add a dependency to a project (requires pyproject.toml):

    Terminal window
    uv add flask

    Adds flask to your pyproject.toml and automatically syncs your environment and updates the uv.lock file.

  • Run a command in the project environment (requires pyproject.toml):

    Terminal window
    uv run python your_script.py

    Runs your_script.py within the project’s virtual environment without explicit activation.

What is uvx?

uvx is part of the uv toolchain, specifically an alias for the uv tool run command. The primary purpose of uvx is to execute Python tools or scripts in a temporary, isolated environment without needing to install them globally or activate a virtual environment first. This is incredibly handy for running tools like linters (e.g., ruff), formatters (e.g., black), or other command-line utilities, ensuring you use a specific version each time without cluttering your global environment.

uvx is a convenient alias for uv tool run. It’s designed for running Python tools in isolated, temporary environments.

  • Run a tool (e.g., ruff) without installing it globally:

    Terminal window
    uvx ruff check your_module.py

    uvx will find or install ruff in a temporary environment, run the check command on your_module.py, and then clean up the environment (though it caches the tool for faster subsequent runs).

  • Run a specific version of a tool:

    Terminal window
    uvx [email protected] your_script.py

    Executes the black formatter version 23.7.0 on your_script.py.

  • Run a tool with extra dependencies:

    Terminal window
    uvx --with 'mypy[extra]' mypy your_module.py

    Runs mypy with its extra dependencies installed in the temporary environment.

  • Run a tool from a specific package name (if different from the command):

    Terminal window
    uvx --from httpie http example.com

    Runs the http command, which is provided by the httpie package.

The difference

Featurepipuvuvx
Core FunctionInstall, uninstall, upgrade, list packagesInstall, resolve, lock packages; manage virtual environmentsRun tools/scripts in a temporary environment
PerformanceRelatively slower, especially with complex dependenciesExtremely fast due to Rust implementationFast startup and execution, no pre-installation needed
Dependency ResolutionImproved resolver in newer versions, but conflict handling can be unclearHighly optimized, clear errors, better conflict resolutionResolves and installs dependencies in a temporary environment
Virtual EnvironmentsRequires separate tools like venv or virtualenv to create/activateBuilt-in virtual environment management, auto-creationRuns in a temporary virtual environment, auto-managed
Lock FilesNeeds tools like pip-tools for requirements.txtSupports generating cross-platform lock files (uv.lock)Uses temporary environments, explicit lock files usually not needed
Tool ExecutionRequires global installation or activated environmentCan be used for project dependencies, uv run for project commandsDirectly runs specified tools/scripts and their deps, no install needed
Ease of UseWidely adopted, extensive documentationIntuitive CLI, some commands compatible with pipSimple command for running one-off tools
InstallationUsually comes with PythonInstallable via standalone script or pip itselfInstalled as part of uv

As the table shows, pip serves as a fundamental and versatile package manager. uv extends this by offering enhanced performance and features for a more modern dependency management experience. uvx, on the other hand, streamlines the process of running standalone tools by providing a convenient “one-off” execution environment.

uv is designed to be a unified replacement for pip and related tools (like pip-tools and virtualenv), aiming for faster performance and a more consistent user experience. uvx builds on uv, further simplifying the execution of individual tools.

4. Summary

In this post, I explained the differences between the uv,uvx and pip commands in Linux. Choosing the right tool ultimately depends on your project’s specific needs and your personal preferences. For most existing projects and scenarios where extreme performance isn’t the top priority, pip remains a reliable choice. For new projects or situations requiring frequent handling of complex dependencies and rapid environment setup, uv is likely a better fit. And uvx is a handy helper for quickly running tools you don’t need installed long-term.

Final Words + More Resources

My intention with this article was to help others who might be considering solving such a problem. So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!