NotImplementedError, what it means and how to fix it

Unlike most errors, this one is raised on purpose and often by design. Base classes and abstract interfaces raise it in placeholder methods to say “subclasses must implement this”; libraries raise it for operations that do not exist on the current platform or plan. It is a signpost, not a malfunction: it tells you the code path you reached is a deliberate dead end, and the work is finding the intended path.

What it looks like

class Storage:
    def save(self, data):
        raise NotImplementedError

class FileStorage(Storage):
    pass                      # forgot to implement save()

FileStorage().save("hello")

Traceback (most recent call last):
  File "main.py", line 9, in <module>
NotImplementedError

The fix, in order

  1. Work out whose placeholder you hit. Read the traceback's deepest frame: if it is your project's base class, the subclass in the next frame up was supposed to override the method. If it is a library's internals, the operation is unsupported there.
  2. Implement the method in the subclass. That is the contract the base class is enforcing. Consider the abc module (@abstractmethod), which moves this failure earlier, to object creation, with a message naming every missing method at once.
  3. If a library raised it, look for the supported alternative named in its docs or the error text (a different backend, a platform-specific sibling function, a newer version). Libraries raise NotImplementedError precisely to stop you silently getting wrong results from a fallback.
  4. Check for platform conditionals. Some operations exist only on one OS (certain file locking, signals, or filesystem features). Code that runs on the developer's OS and raises on deployment is usually this pattern; guard by capability, not by assuming.
  5. Never “fix” it by deleting the raise in a base class or library. The raise is the only thing standing between a missing implementation and silently wrong behavior; implement, subclass, or choose the supported path instead.

If it still happens

If third-party code raises NotImplementedError on a mainstream platform and version, you have usually installed a build or backend that lacks the feature (a minimal wheel, a missing optional dependency). The project's installation docs name the extra that provides it.

Common questions

What is the difference between NotImplementedError and NotImplemented? They are unrelated despite the names. NotImplementedError is an exception class you raise. NotImplemented is a special value that binary special methods (like __eq__) return to tell Python to try the other operand's method. Raising the value, or returning the exception class, are both bugs.

Should my own code raise NotImplementedError or use abstract base classes? Abstract base classes (abc) are the modern enforcement: instantiation fails immediately, listing all unimplemented methods. NotImplementedError remains right for methods that are optional, platform-dependent, or part of interfaces where only some implementations make sense.

Related errors

AssertionError · ImportError · RuntimeError