Imported from nowaytouse/LTSC_Tools_Backup (
src/assets/skills/managing-python-dependencies/SKILL.md). Install upstream withnpx skills add nowaytouse/LTSC_Tools_Backup --skill managing-python-dependencies. Copyright stays with the author (Apache-2.0).
Python Dependency Management Rule
[!CAUTION]
BEFORE any
pip install: You MUST first detect the project's existing dependency manager and use it correctly. Do NOT override the project's established tooling.
Dependency Manager Detection
Before installing ANY Python package, check the workspace for these files in priority order:
- Signal:
uv.lockorpyproject.tomlwith[tool.uv]- Tool: uv
- Install:
uv add <package> - Setup:
uv sync
- Signal:
pyproject.tomlwith[tool.poetry]- Tool: Poetry
- Install:
poetry add <package> - Setup:
poetry install
- Signal:
Pipfile- Tool: Pipenv
- Install:
pipenv install <package> - Setup:
pipenv install
- Signal:
environment.yml- Tool: Conda
- Install:
conda install <package> - Setup:
conda env create -f environment.yml
- Signal:
requirements.txtonly- Tool: venv + pip
- Install:
.venv/bin/pip install <package> - Setup:
.venv/bin/pip install -r requirements.txt
- Signal: None of the above
- Tool: venv + pip (default)
- Install:
.venv/bin/pip install <package> - Setup:
.venv/bin/pip install -r requirements.txt
Default: venv + pip
If no dependency manager is detected, use venv + pip + requirements.txt as the default:
# Initialize environment
python3 -m venv .venv
# Add dependencies
.venv/bin/pip install <package>
# Preserve state
.venv/bin/pip freeze > requirements.txt
Rules for venv + pip workflow:
- Always use
.venv/bin/pipor.venv/bin/python(explicit path). - After installing, run:
.venv/bin/pip freeze > requirements.txt. - When setting up:
.venv/bin/pip install -r requirements.txt.
Prohibited
- NEVER run
pip installglobally - NEVER override an existing dependency manager with a different one