There are several modern alternatives to requirements.txt for Python dependency management:
- Poetry (Recommended)
- More modern dependency management
- Better dependency resolution
- Lock file for deterministic installations
- Project metadata management
This will create a pyproject.toml
[tool.poetry]
name = “django-nextjs-starter”
version = “0.1.0”
description = “”
authors = [“Your Name your.email@example.com“]
[tool.poetry.dependencies]
python = “^3.9”
django = “^4.2.7”
djangorestframework = “^3.14.0”
django-cors-headers = “^4.3.0”
[tool.poetry.dev-dependencies]
pytest = “^7.4.0”
[build-system]
requires = [“poetry-core>=1.0.0”]
build-backend = “poetry.core.masonry.api”
- Pipenv
- Combines pip and virtualenv
- Uses Pipfile and Pipfile.lock
- Deterministic builds
- Conda
- Popular in data science
- Cross-platform package management
- Environment management
For your Django project, I recommend Poetry because:
- Better dependency resolution
- More modern tooling
- Active community
- Better integration with modern Python development practices
To install dependencies with Poetry:
poetry install
To activate the environment:
poetry shell
To add new packages:
poetry add package-name