Tired of setting up virtual environments and managing dependencies for simple Python scripts? Meet uv – the game-changing tool that lets you run Python scripts with external dependencies in seconds, not minutes!
What Makes uv Special?
â
Zero Configuration – No virtual environments, no pip installs
â
Lightning Fast – 10-100x faster than traditional tools
â
Isolated Execution – Each script runs in its own environment
â
PEP 723 Support – Embed dependencies directly in your scripts
â
Cross-Platform – Works seamlessly on Windows, macOS, and Linux
Quick Examples
Run with external dependencies:
#Â APIÂ testing
uv run --with requests test_api.py
# Data analysis
uv run --with pandas --with matplotlib analyze_data.py
# Web scraping
uv run --with beautifulsoup4 --with requests scraper.py
Embed dependencies in your script (PEP 723):
#Â ///Â script
# dependencies = [
#Â Â Â "requests>=2.31.0",
#Â Â Â "rich>=13.0.0"
#Â ]
# requires-python = ">=3.10"
#Â ///
import requests
from rich.console import Console
# Your script code here...
Then simply run: uv run my_script.py
Real-World Use Cases
đ API Testing & Monitoring – Test endpoints without setup overhead đ Data Analysis – Process CSV files with pandas instantly đ·ïž Web Scraping – Extract and convert web content to markdown đ€ Automation Scripts – System administration without environment hassle đ§Ș Prototyping – Experiment with new libraries immediately
Sample Output
$ uv run --with requests github_api_test.py
â
 API Response Status: 200
đąÂ Organization: Astral
đ Location: United States of America
đ„ Public Repos: 47
â°Â Tested at: 2025-01-08 14:30:15
Why Choose uv Over Traditional Methods?
Traditional Approach:
- 1.
Create virtual environment (30s) - 2.
Activate environment (5s) - 3.
Install dependencies (60s+) - 4.
Run script - 5.
Clean up
uv Approach:
uv run --with requests my_script.py  # 2-3 seconds total!
Advanced Features
- Python Version Management : uv run –python 3.11 script.py
- Executable Scripts : Use shebang #!/usr/bin/env -S uv run –script
- Version Constraints : –with ‚requests>=2.31.0,<3.0.0‘
- Multiple Dependencies : Chain multiple –with flags
## Perfect For: - DevOps Engineers – Quick automation scripts
- Data Scientists – Rapid prototyping and analysis
- Web Developers – API testing and content extraction
- System Administrators – Monitoring and maintenance scripts
- Students & Educators – Learning without setup friction
## Get Started Today!
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Run your first script
uv run --with requests my_api_test.py
Ready to revolutionize your Python scripting workflow? uv eliminates the friction between idea and execution, letting you focus on solving problems rather than managing environments.
Full Article
What’s your biggest pain point with Python dependency management? Share in the comments! đ