§
    ¹³Ùgf3  ã                   óº  — d Z ddlZddlmZmZ  ej        e	¦  «        Z
 eddd¬¦  «        Z ed	d
d¬¦  «        Z eddd¬¦  «        Z eddd¬¦  «        Z eddd¬¦  «        Z eddd¬¦  «        Z edd¬¦  «        Z edddœdd¬¦  «        Z ed d!¬¦  «        Z ed"d#¬¦  «        Z ed$d%¬¦  «        Z ed&dd'œd(d)¬¦  «        Z eg d*¢d+¬¦  «        Z ed,d-d.¬¦  «        Z ed/d0¬¦  «        Z ed1d2d3¬¦  «        Z ed4d5d6¬¦  «        Z ed7d8¬¦  «        Z ed9d:¬¦  «        Z ed;d<d=œd>d?¬¦  «        Z ed@dA¬¦  «        Z edBdC¬¦  «        Z  edDdEidFdG¬¦  «        Z! edHdIdJ¬¦  «        Z" edKdL¬¦  «        Z# edMdN¬¦  «        Z$ edOdP¬¦  «        Z% edQdR¬¦  «        Z& edSdT¬¦  «        Z' edUdVdW¬X¦  «        Z( edYdZ¬[¦  «        Z) ed\d]¬[¦  «        Z*dS )^aØ!  
.. currentmodule:: qiskit.utils.optionals

Qiskit has several features that are enabled only if certain *optional* dependencies
are satisfied. This module, :mod:`qiskit.utils.optionals`, has a collection of objects that can
be used to test if certain functionality is available, and optionally raise
:class:`.MissingOptionalLibraryError` if the functionality is not available.


Available Testers
=================

Qiskit Components
-----------------

.. py:data:: HAS_AER

    `Qiskit Aer <https://qiskit.github.io/qiskit-aer/>` provides high-performance simulators for
    the quantum circuits constructed within Qiskit.

.. py:data:: HAS_IBMQ

    The :mod:`Qiskit IBMQ Provider <qiskit.providers.ibmq>` is used for accessing IBM Quantum
    hardware in the IBM cloud.

.. py:data:: HAS_IGNIS

    :mod:`Qiskit Ignis <qiskit.ignis>` provides tools for quantum hardware verification, noise
    characterization, and error correction.

.. py:data:: HAS_TOQM

    `Qiskit TOQM <https://github.com/qiskit-toqm/qiskit-toqm>`__ provides transpiler passes
    for the `Time-optimal Qubit mapping algorithm <https://doi.org/10.1145/3445814.3446706>`__.


External Python Libraries
-------------------------

.. py:data:: HAS_CONSTRAINT

    `python-constraint <https://github.com/python-constraint/python-constraint>`__ is a
    constraint satisfaction problem solver, used in the :class:`~.CSPLayout` transpiler pass.

.. py:data:: HAS_CPLEX

    The `IBM CPLEX Optimizer <https://www.ibm.com/analytics/cplex-optimizer>`__ is a
    high-performance mathematical programming solver for linear, mixed-integer and quadratic
    programming. This is no longer by Qiskit, but it weas historically and the optional
    remains for backwards compatibility.

.. py:data:: HAS_CVXPY

    `CVXPY <https://www.cvxpy.org/>`__ is a Python package for solving convex optimization
    problems.  It is required for calculating diamond norms with
    :func:`.quantum_info.diamond_norm`.

.. py:data:: HAS_DOCPLEX

    `IBM Decision Optimization CPLEX Modelling
    <http://ibmdecisionoptimization.github.io/docplex-doc/>`__ is a library for prescriptive
    analysis.  Like CPLEX, this is no longer by Qiskit, but it weas historically and the
    optional remains for backwards compatibility.

.. py:data:: HAS_FIXTURES

    The test suite has additional features that are available if the optional `fixtures
    <https://launchpad.net/python-fixtures>`__ module is installed.  This generally also needs
    :data:`HAS_TESTTOOLS` as well.  This is generally only needed for Qiskit developers.

.. py:data:: HAS_IPYTHON

    If `the IPython kernel <https://ipython.org/>`__ is available, certain additional
    visualizations and line magics are made available.

.. py:data:: HAS_IPYWIDGETS

    Monitoring widgets for jobs running on external backends can be provided if `ipywidgets
    <https://ipywidgets.readthedocs.io/en/latest/>`__ is available.

.. py:data:: HAS_JAX

    Some methods of gradient calculation within :mod:`.opflow.gradients` require `JAX
    <https://github.com/google/jax>`__ for autodifferentiation.

.. py:data:: HAS_JUPYTER

    Some of the tests require a complete `Jupyter <https://jupyter.org/>`__ installation to test
    interactivity features.

.. py:data:: HAS_MATPLOTLIB

    Qiskit provides several visualization tools in the :mod:`.visualization` module.
    Almost all of these are built using `Matplotlib <https://matplotlib.org/>`__, which must
    be installed in order to use them.

.. py:data:: HAS_NETWORKX

    No longer used by Qiskit.  Internally, Qiskit now uses the high-performance `rustworkx
    <https://github.com/Qiskit/rustworkx>`__ library as a core dependency, and during the
    change-over period, it was sometimes convenient to convert things into the Python-only
    `NetworkX <https://networkx.org/>`__ format.  Some tests of application modules, such as
    `Qiskit Nature <https://qiskit-community.github.io/qiskit-nature/>`__ still use NetworkX.

.. py:data:: HAS_NLOPT

    `NLopt <https://nlopt.readthedocs.io/en/latest/>`__ is a nonlinear optimization library,
    used by the global optimizers in the :mod:`.algorithms.optimizers` module.

.. py:data:: HAS_PIL

    PIL is a Python image-manipulation library.  Qiskit actually uses the `pillow
    <https://pillow.readthedocs.io/en/stable/>`__ fork of PIL if it is available when generating
    certain visualizations, for example of both :class:`.QuantumCircuit` and
    :class:`.DAGCircuit` in certain modes.

.. py:data:: HAS_PYDOT

    For some graph visualizations, Qiskit uses `pydot <https://github.com/pydot/pydot>`__ as an
    interface to GraphViz (see :data:`HAS_GRAPHVIZ`).

.. py:data:: HAS_PYGMENTS

    Pygments is a code highlighter and formatter used by many environments that involve rich
    display of code blocks, including Sphinx and Jupyter.  Qiskit uses this when producing rich
    output for these environments.

.. py:data:: HAS_PYLATEX

    Various LaTeX-based visualizations, especially the circuit drawers, need access to the
    `pylatexenc <https://github.com/phfaist/pylatexenc>`__ project to work correctly.

.. py:data:: HAS_QASM3_IMPORT

    The functions :func:`.qasm3.load` and :func:`.qasm3.loads` for importing OpenQASM 3 programs
    into :class:`.QuantumCircuit` instances use `an external importer package
    <https://qiskit.github.io/qiskit-qasm3-import>`__.

.. py:data:: HAS_SEABORN

    Qiskit provides several visualization tools in the :mod:`.visualization` module.  Some
    of these are built using `Seaborn <https://seaborn.pydata.org/>`__, which must be installed
    in order to use them.

.. py:data:: HAS_SKLEARN

    Some of the gradient functions in :mod:`.opflow.gradients` use regularisation methods from
    `Scikit Learn <https://scikit-learn.org/stable/>`__.

.. py:data:: HAS_SKQUANT

    Some of the optimisers in :mod:`.algorithms.optimizers` are based on those found in `Scikit
    Quant <https://github.com/scikit-quant/scikit-quant>`__, which must be installed to use
    them.

.. py:data:: HAS_SQSNOBFIT

    `SQSnobFit <https://pypi.org/project/SQSnobFit/>`__ is a library for the "stable noisy
    optimization by branch and fit" algorithm.  It is used by the :class:`.SNOBFIT` optimizer.

.. py:data:: HAS_SYMENGINE

    `Symengine <https://github.com/symengine/symengine>`__ is a fast C++ backend for the
    symbolic-manipulation library `Sympy <https://www.sympy.org/en/index.html>`__.  Qiskit uses
    special methods from Symengine to accelerate its handling of
    :class:`~.circuit.Parameter`\ s if available.

.. py:data:: HAS_TESTTOOLS

    Qiskit's test suite has more advanced functionality available if the optional
    `testtools <https://pypi.org/project/testtools/>`__ library is installed.  This is generally
    only needed for Qiskit developers.

.. py:data:: HAS_TWEEDLEDUM

    `Tweedledum <https://github.com/boschmitt/tweedledum>`__ is an extension library for
    synthesis and optimization of circuits that may involve classical oracles.  Qiskit's
    :class:`.PhaseOracle` uses this, which is used in turn by amplification algorithms via
    the :class:`.AmplificationProblem`.

.. py:data:: HAS_Z3

    `Z3 <https://github.com/Z3Prover/z3>`__ is a theorem prover, used in the
    :class:`.CrosstalkAdaptiveSchedule` and :class:`.HoareOptimizer` transpiler passes.

External Command-Line Tools
---------------------------

.. py:data:: HAS_GRAPHVIZ

    For some graph visualizations, Qiskit uses the `GraphViz <https://graphviz.org/>`__
    visualization tool via its ``pydot`` interface (see :data:`HAS_PYDOT`).

.. py:data:: HAS_PDFLATEX

    Visualization tools that use LaTeX in their output, such as the circuit drawers, require
    ``pdflatex`` to be available.  You will generally need to ensure that you have a working
    LaTeX installation available, and the ``qcircuit.tex`` package.

.. py:data:: HAS_PDFTOCAIRO

    Visualization tools that convert LaTeX-generated files into rasterized images use the
    ``pdftocairo`` tool.  This is part of the `Poppler suite of PDF tools
    <https://poppler.freedesktop.org/>`__.


Lazy Checker Classes
====================

.. currentmodule:: qiskit.utils

Each of the lazy checkers is an instance of :class:`.LazyDependencyManager` in one of its two
subclasses: :class:`.LazyImportTester` and :class:`.LazySubprocessTester`.  These should be imported
from :mod:`.utils` directly if required, such as::

    from qiskit.utils import LazyImportTester

.. autoclass:: qiskit.utils.LazyDependencyManager
    :members:

.. autoclass:: qiskit.utils.LazyImportTester
.. autoclass:: qiskit.utils.LazySubprocessTester
é    Né   )ÚLazyImportTesterÚLazySubprocessTesterÚ
qiskit_aerz
Qiskit Aerzpip install qiskit-aer)ÚnameÚinstallzqiskit.providers.ibmqzIBMQ Providerz pip install qiskit-ibmq-providerzqiskit.igniszQiskit Igniszpip install qiskit-ignisÚqiskit_toqmzQiskit TOQMzpip install qiskit-toqmÚ
constraintzpython-constraintzpip install python-constraintÚcplexzpip install cplexz9This may not be possible for all Python versions and OSes)r   ÚmsgÚcvxpyzpip install cvxpy)r   © )ÚModel)Údocplexzdocplex.mp.modelzpip install docplexÚfixtureszpip install fixturesÚIPythonzpip install ipythonÚ
ipywidgetszpip install ipywidgets)ÚgradÚjit)Újaxz	jax.numpyr   zpip install jax)ÚjupyterÚnbformatÚ	nbconvertzpip install jupyter)zmatplotlib.patcheszmatplotlib.pyplotÚ
matplotlibzpip install matplotlibÚnetworkxzpip install networkxÚnloptzNLopt Optimizerzpip install nloptz	PIL.ImageÚpillowzpip install pillowÚpydotzpip install pydotÚpygmentszpip install pygments)ÚLatexNodes2Text)Úutf8tolatex)zpylatexenc.latex2textzpylatexenc.latexencodeÚ
pylatexenczpip install pylatexencÚqiskit_qasm3_importzpip install qiskit_qasm3_importÚseabornzpip install seabornzsklearn.linear_model)ÚRidgeÚLassozscikit-learnzpip install scikit-learnzskquant.optzscikit-quantzpip install scikit-quantÚ	SQSnobFitzpip install SQSnobFitÚ	symenginezpip install symengineÚ	testtoolszpip install testtoolsÚ
tweedledumzpip install tweedledumÚz3zpip install z3-solver)Údotz-VÚGraphvizzÎTo install, follow the instructions at https://graphviz.org/download/. Qiskit needs the Graphviz binaries, which the 'graphviz' package on pip does not install. You must install the actual Graphviz software)r   r   )Úpdflatexz-versionzIYou will likely need to install a full LaTeX distribution for your system)r   )Ú
pdftocairoz-vz2This is part of the 'poppler' set of PDF utilities)+Ú__doc__ÚloggingÚ_loggingÚlazy_testerr   Ú_LazyImportTesterr   Ú_LazySubprocessTesterÚ	getLoggerÚ__name__Ú_loggerÚHAS_AERÚHAS_IBMQÚ	HAS_IGNISÚHAS_TOQMÚHAS_CONSTRAINTÚ	HAS_CPLEXÚ	HAS_CVXPYÚHAS_DOCPLEXÚHAS_FIXTURESÚHAS_IPYTHONÚHAS_IPYWIDGETSÚHAS_JAXÚHAS_JUPYTERÚHAS_MATPLOTLIBÚHAS_NETWORKXÚ	HAS_NLOPTÚHAS_PILÚ	HAS_PYDOTÚHAS_PYGMENTSÚHAS_PYLATEXÚHAS_QASM3_IMPORTÚHAS_SEABORNÚHAS_SKLEARNÚHAS_SKQUANTÚHAS_SQSNOBFITÚHAS_SYMENGINEÚHAS_TESTTOOLSÚHAS_TWEEDLEDUMÚHAS_Z3ÚHAS_GRAPHVIZÚHAS_PDFLATEXÚHAS_PDFTOCAIROr   ó    úL/granary/edev/quantum/lib/python3.11/site-packages/qiskit/utils/optionals.pyú<module>r[      sÿ  ðð^ð ^ðF Ð Ð Ð ðð ð ð ð ð ð ð ð
 ˆ(Ô
˜XÑ
&Ô
&€à
Ð
ØØ	Ø$ðñ ô €ð
 ÐØØ	Ø.ðñ ô €ð
 ÐØØ	Ø&ðñ ô €	ð
 Ð˜]°ÐHaÐbÑbÔb€à"Ð"ØØ	Ø+ðñ ô €ð ÐØØØCðñ ô €	ð
 Ð˜gÐ/BÐCÑCÔC€	ØÐØ¨
Ð3Ð3Ø!ØCðñ ô €ð
 !Ð  Ð5KÐLÑLÔL€ØÐ 	Ð3HÐIÑIÔI€Ø"Ð" <Ð9QÐRÑRÔR€Ø
Ð
Ø¨"Ð-Ð-Ø	Øðñ ô €ð
  ÐÐ DÐ DÐ DÐNcÐdÑdÔd€Ø"Ð"Ø/Ø	Ø$ðñ ô €ð
 !Ð  Ð5KÐLÑLÔL€àÐ˜gÐ,=ÐGZÐ[Ñ[Ô[€	Ø
Ð
˜K¨hÐ@TÐ
UÑ
UÔ
U€ØÐ˜gÐ/BÐCÑCÔC€	Ø Ð  Ð5KÐLÑLÔL€ØÐà!5Ø"2ðð ð 
Ø$ðñ ô €ð %Ð$ØÐ#Dðñ ô Ð ð  Ð 	Ð3HÐIÑIÔI€ØÐØÐ/Ð0Ø	Ø&ðñ ô €ð
  ÐØØ	Ø&ðñ ô €ð
 "Ð! +Ð7NÐOÑOÔO€Ø!Ð! +Ð7NÐOÑOÔO€Ø!Ð! +Ð7NÐOÑOÔO€Ø"Ð" <Ð9QÐRÑRÔR€Ø	Ð	˜4Ð)@Ð	AÑ	AÔ	A€à$Ð$ØØ	ð	9ð	ñ ô €ð %Ð$ØØSðñ ô €ð 'Ð&ØØ<ðñ ô €€€rY   