This guide will walk you through setting up a Python development environment on Windows using uv, an extremely fast Python packager and project manager from the creator of Ruff. Think of uv as a much faster, all-in-one replacement for venv and pip.
- Windows OS
- Python installed (this guide uses Python 3.12 as an example)
- Windows PowerShell
First, we need to install uv. You have two options.
Method 1: Official Script (Recommended)
-
Search for
PowerShellin the Start Menu, then select "Run as Administrator". -
In the administrator PowerShell window, execute the following command to automatically download and install
uv:powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Method 2: Using pip
If you already have a working Python environment, you can also install uv via pip:
pip install uvVerify the Installation
Once installed, run the following command to check the uv version and confirm it was installed correctly.
uv --versionYou should see version output similar to the image below:
A best practice is to create an isolated virtual environment for each project.
-
In your project folder (e.g.,
D:\uv-test), open a PowerShell terminal. -
Use the following command to create a virtual environment named
.venvusing Python 3.12:uv venv --python 3.12
-
Activate the Virtual Environment
To use the new environment, you must activate it.
Note: PowerShell's default security policy may prevent you from running scripts. Run the command below to allow script execution for the current session.
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
When prompted, type
Yand press Enter.Now, run the activation command:
.venv\Scripts\activate
Once activated, your command prompt will be prefixed with
(.venv), as shown below.
With the environment active, you can manage your project's dependencies.
-
Initialize the Project
Running
uv initcreates apyproject.tomlfile in your directory. This file tracks your project's metadata and dependencies, acting as a modern alternative torequirements.txt.uv init
-
Add Dependencies
Let's install some common data science libraries. The
uv addcommand installs packages and automatically adds them to yourpyproject.toml. We'll use the-iflag to specify a faster mirror for quicker downloads.uv add numpy pandas matplotlib scikit-learn seaborn -i https://pypi.tuna.tsinghua.edu.cn/simple
uvwill resolve and install these packages at incredible speed.
You have successfully created a clean, isolated Python development environment with uv.
Next Steps & Common Commands:
- List installed packages:
uv pip list - Deactivate the environment:
deactivate
If you found this guide helpful, feel free to check out my blog at blog.mashijian.com for more hands-on tutorials and tech insights on AI, LLMs and Deep Learning!


