qiskit-optimization is not working on Braket

0

I was going to use Braket in us-east1. I wanted to use qiskit, so I wanted to import the module, but an error occurred.

I referred to the following URL https://qiskit-community.github.io/qiskit-braket-provider/tutorials/3_tutorial_minimum_eigen_optimizer.html

Checking with !pip list, qiskit_optimization is installed without any problem.

【code】

!pip install qiskit
!pip install qiskit-optimization
!pip install qiskit-algorithms

from qiskit import QuantumCircuit, transpile
from qiskit.quantum_info import SparsePauliOp
from qiskit.primitives import Sampler
from qiskit_aer import AerSimulator
from qiskit_optimization import QuadraticProgram
from qiskit_algorithms.minimum_eigensolvers import QAOA
from qiskit_algorithms.optimizers import COBYLA
from qiskit_algorithms import NumPyMinimumEigensolver
from qiskit_optimization.algorithms import MinimumEigenOptimizer

【output】

ModuleNotFoundError                       Traceback (most recent call last)
Cell In[7], line 10
      4 from qiskit_aer import AerSimulator
---> 5 from qiskit_optimization import QuadraticProgram
      6 from qiskit_algorithms.minimum_eigensolvers import QAOA
      7 from qiskit_algorithms.optimizers import COBYLA
      8 from qiskit_algorithms import NumPyMinimumEigensolver
      9 from qiskit_optimization.algorithms import MinimumEigenOptimizer
ModuleNotFoundError: No module named 'qiskit_optimization'

How can I install qiskit_algorithms and qiskit_optimization without problems? I have tried the following.

  • Verify that the module is installed with a !pip list
  • Restart kernel
  • Start another notebook
  • Verify that the installed path of the package is correct
  • Confirm that the module works fine in the local environment
  • use 「%pip install --upgrade qiskit-optimization」 insted of 「!pip install qiskit-optimization」
yuhino
asked a month ago85 views
2 Answers
1
Accepted Answer

Currently qiskit==0.46.x (which is an alias for qiskit-terra) is installed in the Braket notebook instances. This requires a bit of manual work to install the latest qiskit==1.0.x without breaking the dependencies between qiskit packages. Here is a solution which works once executed from a notebook cell, followed by a kernel restart.

%pip uninstall -y qiskit-terra
%pip uninstall -y qiskit
%pip install --upgrade qiskit
%pip install --upgrade qiskit-optimization
%pip install --upgrade qiskit-algorithms

After this, all notebooks (after their kernel restarts) in the same Braket notebook instance will have proper access to the latest qiskit, qiskit-optimization and qiskit-algorithms packages.

answered a month ago
profile picture
EXPERT
reviewed a month ago
0

Thank you so much for your quick and detailed response! I really appreciate it. I was able to solve my problem thanks to your help.

yuhino
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions