Skip to main contentIBM Quantum Documentation

Top-level exceptions



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


qiskit.exceptions.QiskitError(*message)GitHub(opens in a new tab)

Base class for errors raised by Qiskit.

Set the error message.


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.


qiskit.exceptions.MissingOptionalLibraryError(libname, name, pip_install=None, msg=None)GitHub(opens in a new tab)

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:


qiskit.exceptions.QiskitUserConfigError(*message)GitHub(opens in a new tab)

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

Set the error message.


qiskit.exceptions.InvalidFileError(*message)GitHub(opens in a new tab)

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

Set the error message.


Some particular features of Qiskit may raise custom warnings. In general, Qiskit will use built-in Python warnings (such as DeprecationWarning(opens in a new tab)) when appropriate, but warnings related to Qiskit-specific functionality will be subtypes of QiskitWarning.


qiskit.exceptions.QiskitWarningGitHub(opens in a new tab)

Common subclass of warnings for Qiskit-specific warnings being raised.

Related to MissingOptionalLibraryError, in some cases an optional dependency might be found, but fail to import for some other reason. In this case, Qiskit will continue as if the dependency is not present, but will raise OptionalDependencyImportWarning to let you know about it.


qiskit.exceptions.OptionalDependencyImportWarningGitHub(opens in a new tab)

Raised when an optional library raises errors during its import.

When experimental features are being used, Qiskit will raise ExperimentalWarning.


Qiskit experimental features can break at any minor release and their API might change without previous notification. Their use is not recommended in production.


qiskit.exceptions.ExperimentalWarningGitHub(opens in a new tab)

Raised when an experimental feature is being used.

Filtering warnings

Python has built-in mechanisms to filter warnings, described in the documentation of the warnings(opens in a new tab) module. You can use these subclasses in your warning filters from within Python to silence warnings you are not interested in. For example, if you are knowingly using experimental features and are comfortable that they make break in later versions, you can silence ExperimentalWarning like this:

import warnings
from qiskit.exceptions import ExperimentalWarning
warnings.filterwarnings("ignore", category=ExperimentalWarning)
Was this page helpful?