Stop Using Pip - This New Tool is 100x Faster (UV Tutorial)

3 min read 13 days ago
Published on Apr 24, 2025 This response is partially generated with the help of AI. It may contain inaccuracies.

Introduction

This tutorial introduces you to UV, a Python package and project manager that promises to be significantly faster than Pip. If you're currently using Pip or manually managing your virtual environments, transitioning to UV can streamline your workflow and improve your coding efficiency. We'll walk you through the installation and setup process, as well as how to use UV for both scripts and projects.

Step 1: Install UV

To get started with UV, follow these steps for installation:

  1. Visit the UV Installation Documentation
    Go to the UV installation page: UV Install Docs.

  2. Choose Your Installation Method
    You can install UV using pip. Open your terminal and run:

    pip install uv
    
  3. Verify Installation
    Confirm that UV is installed correctly by running:

    uv --version
    

Step 2: Setting Up Python Versions

UV allows you to manage different Python versions seamlessly. Here’s how to set them up:

  1. Check Available Python Versions
    Run the command to list all available Python versions:

    uv pyenv
    
  2. Install a Specific Python Version
    To install a specific version, use:

    uv install <version>
    

    Replace <version> with the desired Python version number.

  3. Set a Default Python Version
    To set a default version for your projects, use:

    uv set <version>
    

Step 3: Using UV for Scripts

Using UV for scripts can enhance speed and efficiency. Follow these steps:

  1. Create a New Script
    Start by creating a new script file. For example:

    uv create-script my_script.py
    
  2. Add Dependencies
    Specify any dependencies required for your script in a requirements.txt file.

  3. Run Your Script
    Execute your script with UV:

    uv run my_script.py
    

Step 4: Using UV for Projects

UV can help manage entire projects efficiently. Here’s how to set it up:

  1. Initialize a New Project
    Create a new project directory:

    uv create-project my_project
    
  2. Navigate to Your Project Directory
    Change to your project directory:

    cd my_project
    
  3. Add Dependencies
    Create a requirements.txt file and list your project’s dependencies.

  4. Install Dependencies
    Use UV to install all dependencies specified:

    uv install
    
  5. Run the Project
    Launch your project using:

    uv run main.py
    

Conclusion

Transitioning from Pip to UV can significantly enhance your Python development experience, especially in terms of speed and efficiency. By following the steps outlined in this tutorial, you can install UV, set up Python versions, and effectively manage scripts and projects.

For further exploration, consider checking the official UV documentation for advanced features and best practices. Happy coding!