| name | uv-package-manager-1-project-initialization |
| description | Sub-skill of uv-package-manager: 1. Project Initialization (+3). |
| version | 1.0.0 |
| category | development |
| type | reference |
| scripts_exempt | true |
1. Project Initialization (+3)
1. Project Initialization
Create a new Python project:
uv init my-project
cd my-project
uv init
uv init --python 3.11
Project structure created:
my-project/
├── .python-version # Python version lock
├── pyproject.toml # Project configuration
├── README.md # Project readme
└── src/
└── my_project/
└── __init__.py
2. Virtual Environment Management
Create and activate virtual environments:
uv venv
uv venv --python 3.11
uv venv .venv-test
source .venv/bin/activate
.venv\Scripts\activate
source .venv/Scripts/activate
List available Python versions:
uv python list
uv python install 3.12
uv python pin 3.11
3. Dependency Management
Add dependencies:
uv add pandas
uv add numpy scipy matplotlib
uv add "pandas>=2.0,<3.0"
uv add --dev pytest pytest-cov ruff
uv add --optional ml tensorflow torch
uv add git+https://github.com/user/repo.git
uv add --editable ../my-local-package
Remove dependencies:
uv remove pandas
uv remove --dev pytest
Sync dependencies:
uv sync
uv sync --dev
uv sync --extra ml
uv sync --all-extras
4. Lock File Management
Understanding uv.lock:
uv lock
uv lock --python 3.11
uv lock --upgrade
uv lock --upgrade-package pandas
Lock file structure:
version = 1
requires-python = ">=3.9"
[[package]]
name = "pandas"
version = "2.2.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "numpy" },
{ name = "python-dateutil" },
{ name = "pytz" },
]