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
- Check the installed version (
pip show pkg) and its docs/changelog - Pin a compatible version in requirements.txt
- Break circular imports by moving the import inside the function or into a third module
Detailed fix by platform
Python
- For circular imports, import the module (
import app.models as models) rather than names, or restructure shared code.
How to diagnose
- Version — Does this version export the name?
- 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026