ImportError 🐍 Python

ImportError: cannot import name 'x' from 'y'

The module was found, but the name you’re importing from it doesn’t exist — usually a version change or a circular import.

Seen on: Python

Meaning

Python loaded the module but the attribute isn’t there. Libraries rename/move things across versions; “(most likely due to a circular import)” in the message means two modules import each other at load time.

Common causes

  • Library version changed/removed the name
  • Circular import between your modules
  • Typo or wrong module path
  • Local file shadowing the real module

⚡ Quick fix

  1. Check the installed version (pip show pkg) and its docs/changelog
  2. Pin a compatible version in requirements.txt
  3. Break circular imports by moving the import inside the function or into a third module

Detailed fix by platform

Python

  1. For circular imports, import the module (import app.models as models) rather than names, or restructure shared code.

How to diagnose

  1. Version — Does this version export the name?
  2. Cycle — Do the modules import each other?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.