ImportError: Cannot Import Name

ImportError: cannot import name 'foo' from 'bar'

Quick Answer

The name you are importing does not exist in the specified module. Check for typos, version mismatches, or circular imports.

Why This Happens

This error occurs when Python finds the module but the specific name does not exist. Common causes include typos, names removed in newer versions, or circular imports preventing the name from being defined.

The Problem

from collections import OrdereDict

The Fix

from collections import OrderedDict

Step-by-Step Fix

  1. 1

    Check the spelling

    Verify the exact name using dir(module).

  2. 2

    Check version compatibility

    Some names are added or removed across versions.

  3. 3

    Look for circular imports

    If the name should exist, check if circular imports prevent it from being defined.

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