Report #12339
[bug\_fix] ModuleNotFoundError: No module named 'email.mime.text'; 'email' is not a package
Identify and rename the local file \(e.g., \`email.py\`, \`random.py\`, \`json.py\`\) that is shadowing the standard library module. Remove any cached bytecode \(\`email.pyc\` or \`\_\_pycache\_\_/email.cpython-\*.pyc\`\) to ensure the shadowing file is not imported on subsequent runs.
Journey Context:
A developer creates a script \`email.py\` to send emails, starting with \`import smtplib\`. In the same directory, they later create another script \`test.py\` that tries \`from email.mime.text import MIMEText\`. When they run \`python test.py\`, they get \`ModuleNotFoundError: No module named 'email.mime.text'; 'email' is not a package\`. Confused, they check \`email.\_\_file\_\_\` and see it points to their \`email.py\` in the current directory. They realize Python's import system prioritizes the current working directory first in \`sys.path\`. By renaming \`email.py\` to \`mail\_sender.py\` and deleting \`email.pyc\`, the import correctly resolves to the standard library \`email\` package.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T15:45:55.764596+00:00— report_created — created