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 requestsThis command installs the latest version of the
requestslibrary from PyPI. -
Install a specific version:
Terminal window pip install flask==2.2.2This installs version 2.2.2 of the
flasklibrary. -
Install from a
requirements.txtfile:Terminal window pip install -r requirements.txtThis is a very common way to install all dependencies listed in a
requirements.txtfile. -
Upgrade a package:
Terminal window pip install --upgrade numpyThis upgrades the
numpypackage to the latest available version. -
Uninstall a package:
Terminal window pip uninstall requestsThis command removes the
requestslibrary from your environment. You will typically be prompted to confirm. -
List installed packages:
Terminal window pip listShows all installed packages and their versions in the current environment.
-
List installed packages in
requirements.txtformat:Terminal window pip freezeOutputs 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 venvThis creates a new virtual environment in a
.venvdirectory 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 requestsSimilar to
pip install, but typically much faster. -
Install from a
requirements.txtfile:Terminal window uv pip install -r requirements.txtInstalls dependencies from a
requirements.txtfile usinguv’s speed. -
Compile a
requirements.txtfile (likepip-compile):Terminal window uv pip compile requirements.in -o requirements.txtReads dependencies from
requirements.inand generates a lockedrequirements.txtwith exact versions. -
Sync an environment with a locked
requirements.txt(likepip-sync):Terminal window uv pip sync requirements.txtInstalls or uninstalls packages to match the exact versions in the
requirements.txtfile. -
Add a dependency to a project (requires
pyproject.toml):Terminal window uv add flaskAdds
flaskto yourpyproject.tomland automatically syncs your environment and updates theuv.lockfile. -
Run a command in the project environment (requires
pyproject.toml):Terminal window uv run python your_script.pyRuns
your_script.pywithin 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.pyuvxwill find or installruffin a temporary environment, run thecheckcommand onyour_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 Executes the
blackformatter version 23.7.0 onyour_script.py. -
Run a tool with extra dependencies:
Terminal window uvx --with 'mypy[extra]' mypy your_module.pyRuns
mypywith itsextradependencies 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.comRuns the
httpcommand, which is provided by thehttpiepackage.
The difference
| Feature | pip | uv | uvx |
|---|---|---|---|
| Core Function | Install, uninstall, upgrade, list packages | Install, resolve, lock packages; manage virtual environments | Run tools/scripts in a temporary environment |
| Performance | Relatively slower, especially with complex dependencies | Extremely fast due to Rust implementation | Fast startup and execution, no pre-installation needed |
| Dependency Resolution | Improved resolver in newer versions, but conflict handling can be unclear | Highly optimized, clear errors, better conflict resolution | Resolves and installs dependencies in a temporary environment |
| Virtual Environments | Requires separate tools like venv or virtualenv to create/activate | Built-in virtual environment management, auto-creation | Runs in a temporary virtual environment, auto-managed |
| Lock Files | Needs tools like pip-tools for requirements.txt | Supports generating cross-platform lock files (uv.lock) | Uses temporary environments, explicit lock files usually not needed |
| Tool Execution | Requires global installation or activated environment | Can be used for project dependencies, uv run for project commands | Directly runs specified tools/scripts and their deps, no install needed |
| Ease of Use | Widely adopted, extensive documentation | Intuitive CLI, some commands compatible with pip | Simple command for running one-off tools |
| Installation | Usually comes with Python | Installable via standalone script or pip itself | Installed 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 share my knowledge and experience. If you want to contact me, you can contact 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!