Skip to content

NotImplementedError

NotImplementedError is a built-in exception that signals a method or function hasn’t been implemented yet.

Typically, you’ll raise NotImplementedError in an abstract base class (ABC) or interface to ensure that subclasses provide their own implementations. This exception also helps flag code that’s intentionally incomplete during development.

NotImplementedError Occurs When

  • Calling a method that explicitly raises this exception to indicate that its implementation doesn’t exist yet

NotImplementedError Can Be Used When

  • Indicating that a method in a base class needs to be implemented in a subclass
  • Serving as a placeholder for future code development
  • Alerting developers to incomplete sections of code during development

NotImplementedError Example

An example of when the exception appears:

Language: Python
>>> class Animal:
...     def speak(self):
...         raise NotImplementedError(
...             "Subclasses must implement this method"
...         )
...

>>> class Dog(Animal):
...     pass
...

>>> dog = Dog()
>>> dog.speak()
Traceback (most recent call last):
    ...
NotImplementedError: Subclasses must implement this method

NotImplementedError How to Fix It

To fix code that raises NotImplementedError, implement the missing method in the subclass:

Language: Python
>>> class Animal:
...     def speak(self):
...         raise NotImplementedError(
...             "Subclasses must implement this method"
...         )
...

>>> class Dog(Animal):
...     def speak(self):
...         print("Woof!")
...

>>> dog = Dog()
>>> dog.speak()
Woof!

Tutorial

Implementing Interfaces in Python: ABCs and Protocols

Learn how to implement interfaces in Python using abstract base classes, Protocols, and duck typing, and enforce method contracts cleanly.

advanced python

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated June 11, 2026 • Reviewed by Martin Breuss