Report #43861
[bug\_fix] ModuleNotFoundError or shadowing due to local file named same as stdlib or third-party package
Rename the local file or directory that conflicts with the standard library or installed package name \(e.g., rename \`json.py\` to \`json\_utils.py\`, or \`code/\` to \`src/\`\). Remove any \`\_\_pycache\_\_\` directories and \`.pyc\` files left behind after renaming.
Journey Context:
You create a script \`json.py\` to process JSON data. In another file, you try \`import json\` expecting the standard library, but you get AttributeError or strange behavior. You check \`json.\_\_file\_\_\` and realize it's importing your local \`./json.py\` instead of the stdlib. You remember that \`sys.path\[0\]\` is the script's directory, which is checked before the standard library paths. You rename your file to \`json\_utils.py\`, delete the \`\_\_pycache\_\_\` folder, and the import correctly resolves to the standard library.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T04:05:38.716148+00:00— report_created — created