Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Python Environment Management with uv
- uv is a high-performance Python package and project manager written in Rust. Here's how to use it effectively:
- ### Installing Python Versions
- ```bash
- # Install multiple Python versions
- uv python install 3.10 3.11 3.12
- # Pin a specific Python version for a project
- uv python pin 3.11
- ```
- ### Virtual Environment Management
- ```bash
- # Create a new virtual environment
- uv venv --python 3.12.0
- # Activate the virtual environment
- source .venv/bin/activate
- ```
- ### Package Management
- ```bash
- # Initialize a new project
- uv init project_name
- # Add a package to your project
- uv add package_name
- # Run a Python tool directly without installation
- uvx tool_name command
- # Install a tool globally
- uv tool install tool_name
- ```
- ### Requirements Management
- ```bash
- # Compile requirements file
- uv pip compile requirements.in --universal --output-file requirements.txt
- # Install dependencies from requirements file
- uv pip sync requirements.txt
- ```
- ## Important Notes
- 1. Environment Activation:
- - Check if virtual environment activation is needed before running commands
- - Use `source .venv/bin/activate` to activate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement