all Python 3Exceptionsexception
zipimport.ZipImportError
module exceptions
A module could not be imported from a ZIP archive (a subclass of ImportError).
Syntax
raise zipimport.ZipImportError
It subclasses ImportError, so a plain except ImportError already catches it; a dedicated branch pays off only when you need to tell a broken archive apart from a module that simply isn't there. It comes from the zipimport machinery: zipimporter(path) raises it when the path doesn't point to a readable ZIP archive. You almost never raise it yourself — it shows up on its own once a .zip entry lands on sys.path.
Examples
import zipimport
try:
raise zipimport.ZipImportError
except zipimport.ZipImportError as e:
print(type(e).__name__) # → ZipImportError
See also
Open in the full glossarydocs.python.orgReport an inaccuracy