Python Glossary Русский

all Python 3Exceptionsexception

ImportWarning

built-in exceptions

A possible mistake in module import (hidden by default).

Syntax

raise ImportWarning

This is a warning, not a failure: execution continues, and by default you never see the message at all, because the standard warnings filters drop ImportWarning. Run python -W default or python -X dev to make it visible. You almost never raise it yourself — it comes from the import machinery and points at odd package or path setups rather than at a mistake in your own import statement.

Examples

try:
    raise ImportWarning
except ImportWarning as e:
    print(type(e).__name__)   # → ImportWarning

See also

Open in the full glossarydocs.python.orgReport an inaccuracy