Back to blog

From pip to uv for your next python project

Moving from pip to uv for faster dev loop

Okay, let's get you started with uv (and uvx!) as a Python developer coming from pip. It's a great move, as uv is significantly faster than pip for many operations. Think of it as a speed upgrade for your Python package management!

Here's a step-by-step guide to help you transition, focusing on the basics and keeping it simple:

1. Understanding uv and uvx (Very Briefly)

  • uv: Imagine uv as a super-fast, efficient replacement for the core parts of pip. It's built in Rust (a fast programming language) and focuses on speed for installing, uninstalling, and resolving Python packages. It's designed to be mostly compatible with pip commands, which makes transitioning easier.

  • uvx: Think of uvx as a "batteries-included" version built on top of uv. It's not just a package installer. uvx also includes features for creating virtual environments (venv), running tasks, and potentially more in the future. It's a more comprehensive tool.

For a Python developer starting out, I recommend starting with just uv first. It's simpler to grasp the direct pip replacement. You can explore uvx later once you're comfortable with uv.

2. Installation

The installation process for uv is quite straightforward. It's designed to be easy to install.

Platform-Specific Instructions:

  • macOS/Linux: Open your terminal and run this command:

    Bash
    curl -fsSL https://install.astral.sh/uv.sh | sh
    
    This will download and run a script that installs uv in your system.

  • Windows: The easiest way on Windows is using scoop (a command-line installer for Windows). If you don't have scoop, install it first (follow instructions on https://scoop.sh/). Then, in your PowerShell or Command Prompt:

    Bash
    scoop install uv
    

  • Other Platforms (or if the above methods don't work): Check the official uv documentation for more installation options if needed: https://docs.astral.sh/uv/getting-started/installation/ (Look for the installation section there).

Verify Installation:

After installation, open a new terminal window (or restart your current one) and type:

Bash
uv --version

If it shows a version number (like uv 0.x.x), then uv is installed correctly!

3. Basic uv Usage - Replacing pip Commands

The beauty of uv is that many of the commands you're used to in pip have direct equivalents in uv. Here's a table showing common pip commands and their uv counterparts:

pip Commanduv EquivalentDescription
pip install <package_name>uv pip install <package_name>Installs a package (e.g., uv pip install requests)
pip install <package1> <package2>uv pip install <package1> <package2>Installs multiple packages
pip install -r requirements.txtuv pip install -r requirements.txtInstalls packages listed in a requirements.txt file
pip uninstall <package_name>uv pip uninstall <package_name>Uninstalls a package (e.g., uv pip uninstall requests)
pip freeze > requirements.txtuv pip freeze --requirements-txt > requirements.txtCreates a requirements.txt file listing installed packages and their versions (important: use --requirements-txt)
pip listuv pip listLists installed packages

Examples - Let's say you want to work with the requests library:

  • Using pip (the old way):

    Bash
    pip install requests
    

  • Using uv (the new, faster way):

    Bash
    uv pip install requests
    
    Notice the only change is replacing pip with uv pip. That's it for most basic operations!

4. Transitioning Your Existing Projects

If you have existing Python projects that use pip and requirements.txt, here's how you can transition to using uv:

  1. Make sure you are in your project's virtual environment (if you're using one, which is highly recommended for projects to keep dependencies isolated). If you're not using virtual environments yet, that's a slightly more advanced topic, but for now, just navigate to your project directory in the terminal.

  2. Install your project's dependencies using uv:If you have a requirements.txt file in your project, simply run:

    Bash
    uv pip install -r requirements.txt
    
    uv will read your requirements.txt and install all the packages listed there, but much faster than pip would.

  3. From now on, use uv pip instead of pip for managing packages in this project.For example, if you need to add a new package to your project:

    Bash
    uv pip install new_package_name
    
    If you need to update your requirements.txt with the current project's dependencies:
    Bash
    uv pip freeze --requirements-txt > requirements.txt
    

5. What about uvx? (Optional - Explore later)

uvx is more than just a pip replacement. It includes venv functionality, which is useful for creating virtual environments. If you want to try uvx later:

  • Installation: uvx is installed as part of the uv installation. You don't need to install it separately.

  • Virtual Environments with uvx: Instead of using python -m venv my_venv or virtualenv my_venv, you can use:

    Bash
    uv venv my_venv
    
    This will create a virtual environment named my_venv using uv's fast venv creation. You would then activate it as usual (e.g., source my_venv/bin/activate on macOS/Linux, my_venv\Scripts\activate on Windows).Important: For now, if you're just starting, focusing on using uv pip as a replacement for pip is the most straightforward transition. You can explore uv venv and other uvx features later.

6. Important Notes and Tips for Developers:

  • Virtual Environments are Still Important: Whether you use pip or uv, it's still highly recommended to use virtual environments for your Python projects. This keeps project dependencies isolated and prevents conflicts. uv works perfectly well with virtual environments created by venv (Python's built-in virtual environment tool) or uv venv.

  • Compatibility: uv is designed to be highly compatible with pip. In most cases, it will work seamlessly as a replacement. However, there might be very rare edge cases where you encounter differences. If you do, double-check the uv documentation or report an issue if you think it's a bug.

  • Speed is the Main Benefit: You'll notice the speed difference most when installing many packages or resolving complex dependency trees. For small projects with few dependencies, the difference might be less dramatic, but it's still generally faster.

  • Start Simple: For now, just focus on replacing pip commands with uv pip commands. That's the core transition. Don't feel pressured to immediately use all the features of uvx.

  • Documentation: If you need more details or run into any issues, the official uv documentation is your best resource: https://docs.astral.sh/uv/

Summary:

  1. Install uv using the instructions for your operating system.

  2. Verify installation with uv --version.

  3. Start using uv pip instead of pip for your package management needs (installing, uninstalling, listing, freezing).

  4. For existing projects, use uv pip install -r requirements.txt to install dependencies.

  5. Stick with uv pip for now. Explore uvx and its venv features later when you're more comfortable.

  6. Enjoy the faster package management!

Subscribe to our newsletter

Sign up to our company blog and get the latest insights from Codelinter. Learn more about our services, community posts and more.

Codelinter: 2025