RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /Python for AI — Zero to Useful
  6. /Ch. 29
Python for AI — Zero to Useful

29. Dependency Management

Chapter 29 of 36 · 15 min
KEY INSIGHT

For AI projects specifically, dependency hell is real. CUDA versions, numpy builds with different BLAS libraries, torch with CUDA versus CPU builds—all require careful environment management. Poetry and pip-tools both help, but for GPU-dependent projects, consider Docker containers where the base image pins everything.

pip freeze > requirements.txt captures exact versions, but it plasters over every transitive dependency too. Modern tools give you more control.

pip-tools for coordinated dependency management:

# Install pip-tools
pip install pip-tools

# Create requirements.in (your direct dependencies)
# openai>=1.0.0
# pandas>=2.0.0
# matplotlib>=3.7.0

# Compile to requirements.txt with pinned versions
pip-compile -o requirements.txt requirements.in

# Now requirements.txt has openai, pandas, matplotlib AND all their deps
# with pinned versions

# Before creating venv, sync it
pip-sync requirements.txt

poetry as an all-in-one alternative (recommended for new projects):

# Install poetry
curl -sSL https://install.python-poetry.org | python3 -

# Initialize new project
poetry new ai-pipeline
cd ai-pipeline

# Add dependencies
poetry add openai pandas

# Add dev dependencies
poetry add --dev pytest black

# lock and install
poetry install

# Run scripts in the environment
poetry run python script.py
poetry run pytest

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

EXERCISE

Create a new directory with a pyproject.toml file. Use poetry to initialize it, add requests and click as dependencies, install them, write a small Python script that uses both, and run it with poetry run.

← Chapter 28
Virtual Environments Deep Dive
Chapter 30 →
Project Structure for AI