Python uv: No More Manual Virtual Environments

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 | uv run python 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
npm init -y
npm install express
node server.js
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 thanpip
.Consistency: Automatic lock files ensure reproducible builds.
Unified experience: Just like JavaScript developers rely on
npm
, Python developers can now rely onuv
.
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
uv init testApi
cd testApi
it will Create
run this
uv run main.py
its creates everything automatically
2. Add Dependencies
uv add fastapi uvicorn
same npm i packagename
it will add dependency in pyproject.toml — same as package.json
3. Add a Basic FastAPI App
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
Boom….
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.
Subscribe to my newsletter
Read articles from Has directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by