ImportWarning
PythonWARNINGCommonWarning

Probable mistake in module import

Quick Answer

Enable with -W all to surface ImportWarnings; check for missing __init__.py or sys.path ordering issues.

Production Risk

Low.

What this means

Raised when a probable mistake is detected in an import statement, such as a missing __init__.py or a shadowed module name. Silenced by default.

Why it happens
  1. 1Importing a package directory that lacks __init__.py in Python 2 legacy code
  2. 2A local file shadows a standard library module name

Fix

Enable and fix import path issues

Enable and fix import path issues
# Diagnose:
python -W all -c "import my_module"

# Fix shadowed names by renaming the local file
# Fix missing __init__.py by adding it to the package directory

Why this works

ImportWarning surfaces import path problems that would otherwise silently use the wrong module.

Same error in other languages
Sources

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Python errors