Advertisement
Guest User

uv-short

a guest
Feb 19th, 2025
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. ## Python Environment Management with uv
  2.  
  3. uv is a high-performance Python package and project manager written in Rust. Here's how to use it effectively:
  4.  
  5. ### Installing Python Versions
  6. ```bash
  7. # Install multiple Python versions
  8. uv python install 3.10 3.11 3.12
  9.  
  10. # Pin a specific Python version for a project
  11. uv python pin 3.11
  12. ```
  13.  
  14. ### Virtual Environment Management
  15. ```bash
  16. # Create a new virtual environment
  17. uv venv --python 3.12.0
  18.  
  19. # Activate the virtual environment
  20. source .venv/bin/activate
  21. ```
  22.  
  23. ### Package Management
  24. ```bash
  25. # Initialize a new project
  26. uv init project_name
  27.  
  28. # Add a package to your project
  29. uv add package_name
  30.  
  31. # Run a Python tool directly without installation
  32. uvx tool_name command
  33.  
  34. # Install a tool globally
  35. uv tool install tool_name
  36. ```
  37.  
  38. ### Requirements Management
  39. ```bash
  40. # Compile requirements file
  41. uv pip compile requirements.in --universal --output-file requirements.txt
  42.  
  43. # Install dependencies from requirements file
  44. uv pip sync requirements.txt
  45. ```
  46.  
  47. ## Important Notes
  48.  
  49. 1. Environment Activation:
  50. - Check if virtual environment activation is needed before running commands
  51. - Use `source .venv/bin/activate` to activate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement