# Python uv:  No More Manual Virtual Environments

```python
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```

But now, a new tool called `uv` makes this entire process seamless.

That changes with `uv`, a new **ultra-fast Python package manager and runtime** by Astral (creators of Ruff).

With `uv`, managing Python dependencies feels more like using `npm` in Node.js:

* No manual virtual environment setup.
    
* Simple commands to install and run.
    
* Automatic isolation per project.
    

Why `uv` Feels Like `npm`

## Why `uv` Feels Like `npm`

Let’s compare side by side:

| Task | Old Python Way (`pip + venv`) | With `uv` | Node.js (`npm`) |
| --- | --- | --- | --- |
| Create project | `mkdir app && cd app && python -m venv .venv` | `uv init app` | `mkdir app && cd app && npm init -y` |
| Add dependency | `pip install requests` | `uv add requests` | `npm install axios` |
| Track dependencies | `requirements.txt` (manual update) | `pyproject.toml` (auto updated) | `package.json` (auto updated) |
| Run script | `source .venv/bin/activate && python` [`script.py`](http://script.py) | `uv run python` [`script.py`](http://script.py) | `node script.js` |
| Lock versions | `pip-tools` or manual | Built-in lockfile | `package-lock.json` |
| Global tool install | `pip install --user tool` | `uv tool install tool` | `npm install -g tool` |

Example: Installing and Running a Project

```javascript
npm init -y
npm install express
node server.js
```

```python
uv init my-app
uv add fastapi uvicorn
uv run uvicorn app:app --reload
```

Notice how both flows look **almost identical**. No `venv` step in Python anymore.

Why This Matters

## Why This Matters

* **Beginner friendly**: New Python devs don’t need to learn about virtual environments right away.
    
* **Faster installs**: `uv` is significantly faster than `pip`.
    
* **Consistency**: Automatic lock files ensure reproducible builds.
    
* **Unified experience**: Just like JavaScript developers rely on `npm`, Python developers can now rely on `uv`.
    

## Conclusion

Python has long lagged behind JavaScript in developer experience when it comes to dependency management. With `uv`, Python is finally catching up — giving us an **npm-like workflow** that’s simple, fast, and reliable.

If you’re tired of typing `python -m venv .venv && source .venv/bin/activate`, it’s time to try `uv`.

## Let’s create a **FastAPI project** step by step… with UV + Python

## 1\. Initialize a New Project

```python
uv init testApi
cd testApi
```

it will Create

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1756106700805/13188a0b-f999-4b00-8a10-f300f566eda4.png align="left")

run this

```powershell
uv run main.py
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1756106840829/38ae2b03-2ef4-40e8-8b74-064bbbaf958b.png align="left")

its creates everything automatically

## 2\. Add Dependencies

```powershell
uv add fastapi uvicorn
```

same <mark>npm i packagename</mark>

it will add dependency in <mark>pyproject.toml </mark> — same as <mark>package.json</mark>

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1756107028174/9cef9dd0-bdad-4ed4-b4e2-c594041134e3.png align="left")

## 3\. Add a Basic FastAPI App

```python
from fastapi import FastAPI
import uvicorn
def main():
    print("Hello from ocr!")
    uvicorn.run(app, host="0.0.0.0", port=7000)


app = FastAPI()

@app.get("/")
async def root():
    return {"message":"i am python FastAPI"}


if __name__ == "__main__":
    main()
```

## 4\. Run the App

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1756107477734/66349d05-0940-4512-ae17-d11ac40afeed.png align="center")

Boom….

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1756107540959/847742b5-707b-4229-b2c0-26c95f4bac84.png align="left")

## 5\. Summary

* `uv` = automatic environment + package manager (like npm)
    
* FastAPI project is ready in minutes
    
* No manual venv, no pip hassles
    
* Run scripts with `uv run`
    

🚀 Exploring **FastAPI with** `uv` — no virtual environments, no hassle, just Python done right! Stay tuned, more insights coming soon.
