Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK. Go to the latest version.

Top-level exceptions

qiskit.exceptions

All Qiskit-related errors raised by Qiskit are subclasses of the base:

QiskitError

exception qiskit.exceptions.QiskitError(*message)

GitHub

Base class for errors raised by Qiskit.

Set the error message.

Note

Errors that are just general programming errors, such as incorrect typing, may still raise standard Python errors such as TypeError. QiskitError is generally for errors raised in usage that is particular to Qiskit.

Many of the Qiskit subpackages define their own more granular error, to help in catching only the subset of errors you care about. For example, qiskit.circuit almost exclusively uses CircuitError, while both QASM2ExportError and QASM2ParseError derive from QASM2Error in qiskit.qasm2, which is in turn a type of QiskitError.

Qiskit has several optional features that depend on other packages that are not required for a minimal install. You can read more about those, and ways to check for their presence, in qiskit.utils.optionals. Trying to use a feature that requires an optional extra will raise a particular error, which subclasses both QiskitError and the Python built-in ImportError.

MissingOptionalLibraryError

exception qiskit.exceptions.MissingOptionalLibraryError(libname, name, pip_install=None, msg=None)

GitHub

Raised when an optional library is missing.

Set the error message. :param libname: Name of missing library :param name: Name of class, function, module that uses this library :param pip_install: pip install command, if any :param msg: Descriptive message, if any

Two more uncommon errors relate to failures in reading user-configuration files, or specifying a filename that cannot be used:

QiskitUserConfigError

exception qiskit.exceptions.QiskitUserConfigError(*message)

GitHub

Raised when an error is encountered reading a user config file.

Set the error message.

InvalidFileError

exception qiskit.exceptions.InvalidFileError(*message)

GitHub

Raised when the file provided is not valid for the specific task.

Set the error message.

Was this page helpful?
Report a bug or request content on GitHub.