Skip to main content

Python dependency injection framework

Project description

Dependency Injector is a Python dependency injection framework. It was designed to be unified, developer-friendly tool for managing any kind of Python objects and their dependencies in formal, pretty way.

Dependency Injector framework key features are:

  • Easy, smart, pythonic style.
  • Obvious, clear structure.
  • Extensibility and flexibility.
  • Memory efficiency.
  • Thread safety.
  • Documentation.
  • Semantic versioning.


PyPi Latest Version Downloads License
Python versions and implementations Supported Python versions Supported Python implementations
Builds and tests coverage Build Status Coverage Status


Dependency Injector library is available on PyPi:

pip install dependency_injector


"""Dependency Injector example."""

import sys
import sqlite3

from boto.s3.connection import S3Connection

from dependency_injector import catalogs
from dependency_injector import providers
from dependency_injector import injections

from example import services

class Platform(catalogs.DeclarativeCatalog):
    """Catalog of platform service providers."""

    database = providers.Singleton(sqlite3.connect, ':memory:')

    s3 = providers.Singleton(S3Connection,

class Services(catalogs.DeclarativeCatalog):
    """Catalog of business service providers."""

    users = providers.Factory(services.Users,

    photos = providers.Factory(services.Photos,

    auth = providers.Factory(services.Auth,

def main(argv, users_service, auth_service, photos_service):
    """Main function."""
    login, password, photo_path = argv[1:]

    user = users_service.get_user(login)
    auth_service.authenticate(user, password)
    photos_service.upload_photo(user['id'], photo_path)

if __name__ == '__main__':

You can get more Dependency Injector examples in /examples directory on GitHub:


Dependency Injector documentation is hosted on ReadTheDocs:


Feel free to post questions, bugs, feature requests, proposals etc. on Dependency Injector GitHub Issues:

Your feedback is quite important!

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dependency-injector, version 1.16.5
Filename, size File type Python version Upload date Hashes
Filename, size dependency_injector-1.16.5.tar.gz (23.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page