Skip to content

ImportError vs ModuleNotFoundError #2436

@seisman

Description

@seisman

In the current source codes, sometimes we use ImportError and sometimes ModuleNotFoundError, e.g.,

except ImportError:

except ModuleNotFoundError:

ModuleNotFoundError is a subclass of ImportError (https://docs.python.org/3/library/exceptions.html#ModuleNotFoundError). As per https://www.scivision.dev/python-importerror-vs-modulenotfound/, maybe we should always use ImportError.

ref: https://stackoverflow.com/questions/62854761/python3-8-whats-the-difference-between-importerror-and-modulenotfounderror

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintenanceBoring but important stuff for the core devs

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions