Qiskit in Colab

103 views Asked by At

I'm running a simple script in Google Colab, but it gives an error in the line: job = execute(circ, backend, shots=1)

 TranspilerError: 'Invalid plugin name sabre for stage routing' 

Could someone point the issue with the code?

Here is the code:

#Install Qiskit in the Colab environment
!pip install qiskit qiskit-ibmq-provider qiskit-aer

# Correctly import necessary modules
from qiskit import QuantumCircuit
from qiskit.providers.ibmq import IBMQ  
from qiskit.providers.ibmq import least_busy
from qiskit_aer import Aer
from qiskit.execute_function import execute  

IBMQ.save_account('API_TOKEN', overwrite=True)

IBMQ.load_account()

backend = IBMQ.get_provider().get_backend('ibmq_qasm_simulator')
# Create one qubit
circ = QuantumCircuit(1, 1)
# Put the qubit in superposition (0 and 1 at the same time)
circ.h(0)
# Measure the qubit
circ.measure(0, 0)
# Run the circuit on the local simulator
job = execute(circ, backend, shots=1)
1

There are 1 answers

0
Roy Elkabetz On

The qiskit.execute_function was removed in qiskit-1.0 (see releasenote).

Instead of using the execute function, just run the following

# transpile to backend
circ_ = transpile(circ, backend=backend)
job = backend.run(circ_)
result = job.result()
counts = result.get_counts()
counts