`uv`: A Faster Python Package Management Tool
# Mastering `uv`: A Fast Python Package Manager
Python package managers let you install and manage dependencies—such as **NumPy**, **pandas**, and more—directly from your terminal.
In this guide, you’ll learn how to use **uv**, an extremely fast and modern Python package manager.
---
## Prerequisites
Before starting, you should:
- Know how to execute commands in your terminal
- Be familiar with basic Python development or scripting
---
## Table of Contents
- [Why Use uv?](#why-use-uv)  
- [Install uv](#install-uv)  
- [Create a New Project](#create-a-new-project)  
- [Common uv Commands](#common-uv-commands)  
  - [Add a Dependency](#add-a-dependency)  
  - [Remove a Dependency](#remove-a-dependency)  
  - [Run Python Code](#run-python-code)  
  - [Move Your Project](#move-your-project)  
  - [Add and Run Tools](#add-and-run-tools)  
  - [Run Tools Without Adding](#run-tools-without-adding)  
  - [Manage Multiple Python Versions](#manage-multiple-python-versions)  
  - [Migrate from pip](#migrate-from-pip)  
- [Conclusion](#conclusion)
---
## Why Use uv?
**uv** is a free, open-source Python project management tool written in Rust. It is:
- **Blazingly fast**
- **Easy to use**
- Capable of managing virtual environments and dependencies in one place
According to [speed tests](https://docs.astral.sh/uv/), uv outperforms other popular package managers in installation speed.
---
## Install uv
### On Linux/macOS:curl -LsSf https://astral.sh/uv/install.sh | sh
### On Windows:powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
---
## Create a New Project
Run:uv init freecodecamp-project
This creates a `freecodecamp-project/` folder with:
├── .gitignore # git ignore rules
├── .python-version # your Python version
├── README.md # documentation
├── main.py # main Python script
└── pyproject.toml # configuration (name, version, dependencies)
---
## Common uv Commands
First, go to your project folder:cd freecodecamp-project
---
### Add a Dependency
To add **NumPy**:uv add numpy
or specify a version:
uv add 'numpy==2.3.0'
This creates:├── .venv # virtual environment
└── uv.lock # exact dependency versions
> **Note:** Never edit the `.lock` file manually.
---
### Remove a Dependency
uv remove numpy
Removes NumPy from the `.lock` file and the virtual environment.
---
### Run Python Code
uv run main.py
Executes your script within the virtual environment—no manual activation required.
---
### Move Your Project
Copy the project folder to another machine, then run:uv sync --locked
Installs dependencies with **exact recorded versions**.
---
### Add and Run Tools
Install **ruff** (a linter):uv add ruff
Run:uv run ruff check
---
### Run Tools Without Adding
One-off run:uv tool run ruff check
or equivalently
uvx ruff check
Runs the tool in an isolated environment without adding it to dependencies.
---
### Manage Multiple Python Versions
Install latest Python
uv python install
Install specific versions
uv python install 3.11 3.12
List installed versions
uv python list
Pin version for current project
uv python pin 3.11
---
### Migrate from pip
Use `uv` as a drop-in replacement:uv pip install -r requirements.txt
---
## Conclusion
`uv` dramatically simplifies Python dependency management, virtual environments, and version control—all with impressive speed.
For more, see the [uv documentation](https://docs.astral.sh/uv/).
---
### Bonus: Streamlining Content Creation
If you also publish Python or AI-generated content, **[AiToEarn](https://aitoearn.ai/)** offers an open-source AI content monetization ecosystem:
- Generate with AI
- Publish to **Douyin, Kwai, WeChat, Bilibili, Xiaohongshu, Facebook, Instagram, LinkedIn, Threads, YouTube, Pinterest, X (Twitter)** simultaneously
- Track analytics  
- Rank AI models
Read the [AiToEarn blog](https://blog.aitoearn.ai/) or explore their [GitHub](https://github.com/yikart/AiToEarn) for technical details.
Combining `uv` with AiToEarn can give developers and creators a **fast, unified workflow** for coding, publishing, and monetizing content.