from qiskit.circuit import QuantumCircuit, ParameterVector
p = ParameterVector('p', 58)
sum = [0 for _ in range(58)]

# my code is in here such like
# for i in range(n):
#    ATCQNN_CIRCUIT.rx(p[i], i)

ATCQNN_CIRCUIT.bind_parameters({p: sum})
# instead of the above line, I tried also this below one...
# ATCQNN_CIRCUIT.bind_parameters({p[i]: sum[i] for i in range(58)})

ATCQNN_CIRCUIT.measure(range(4), range(4))
ATCQNN_CIRCUIT.decompose().draw('mpl', fold=40)

from qiskit import BasicAer, execute
backend = BasicAer.get_backend('qasm_simulator')
results = execute(ATCQNN_CIRCUIT, backend).result()
a = results.get_counts(ATCQNN_CIRCUIT)

So I could check there has correct parameter bindingenter image description here

and there has correct circuit drawing.enter image description here

However, if I tried to execute on basicAer, as I wrote my code, then it makes some error

'Mismatch between run_config.parameter_binds and all circuit parameters. Parameter binds: [] Circuit parameters: [ParameterView([ParameterVectorElement(x[0]), ParameterVec

enter image description here

Please save me from this one ...


1 Answer 1


The QuantumCircuit.bind_parameters method per default returns a copy. You should try modifying your code to either

ATCQNN_CIRCUIT.bind_parameters(sum, inplace=True)


bound_circuit = ATCQNN_CIRCUIT.bind_parameters(sum)

Note that it is not necessary to pass a dictionary with the parameter vector, but you can just pass the parameter values as list. They will be bound to the vector sorted by index.

  • $\begingroup$ I'm honored... Thank you very much. The second one exactly solved my problem. $\endgroup$
    – shc
    Aug 8, 2023 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.