Report #102415
[bug\_fix] AttributeError: partially initialized module 'json' has no attribute 'loads' \(or bizarre behavior from any stdlib module\)
Rename your local file or package so it does not match a standard-library or installed third-party module name. Common offenders: \`json.py\`, \`random.py\`, \`test.py\`, \`email.py\`, \`copy.py\`, \`code.py\`, \`site.py\`. Then delete any leftover \`\_\_pycache\_\_\` and \`.pyc\` files in that directory.
Journey Context:
You create a quick script named \`json.py\` to test serialization. In the same directory you run \`python app.py\`, which imports the standard-library \`json\`. Python's module search path puts the directory containing the script first \(\`sys.path\[0\]\`\), so it finds your \`json.py\` instead of the stdlib module. Your file does not define \`loads\`, so any call to \`json.loads\` fails with AttributeError, or worse, partially works and produces silent bugs. The error is maddening because \`import json\` succeeds—just the wrong \`json\`. The fix works because removing the shadowing name restores the search order: the next entry in \`sys.path\` is the standard library, so the real \`json\` module is loaded.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T04:50:03.678380+00:00— report_created — created