TypeError: Missing Required Positional Argument

TypeError: __init__() missing 1 required positional argument: 'name'

Quick Answer

You called a function or class constructor without providing all required arguments. Check the function signature for required parameters and supply them.

Why This Happens

When a function defines parameters without default values, Python requires you to pass a value for each one. This commonly appears with class __init__ methods where you forget to pass constructor arguments.

The Problem

class User:
    def __init__(self, name, email):
        self.name = name
        self.email = email

user = User('Alice')

The Fix

class User:
    def __init__(self, name, email):
        self.name = name
        self.email = email

user = User('Alice', 'alice@example.com')

Step-by-Step Fix

  1. 1

    Read the error message

    The error tells you exactly which argument is missing.

  2. 2

    Check the function definition

    Review the parameter list to see what is required.

  3. 3

    Add default values if appropriate

    Add a default: def __init__(self, name, email=None).

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free