AttributeError: Partially Initialized Module (Circular Import)
AttributeError: partially initialized module 'json' has no attribute 'loads' (most likely due to a circular import)Quick Answer
You have a file with the same name as a standard library module, causing a circular import. Rename your file so it does not shadow the built-in module.
Why This Happens
When Python imports a module, it searches the current directory first. If you have a file named json.py, random.py, or os.py, Python imports your file instead of the standard library. Your file then tries to import the real module but finds itself.
The Problem
# File named json.py
import json
data = json.loads('{"key": "value"}')The Fix
# Rename file to json_parser.py
import json
data = json.loads('{"key": "value"}')Step-by-Step Fix
- 1
Check for file name conflicts
Look for .py files that share a name with standard library modules.
- 2
Rename the conflicting file
Also delete any .pyc cache in __pycache__.
- 3
Verify the import
Run print(json.__file__) to confirm which module is imported.
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