1
$\begingroup$

I'm trying to generate random numbers using IBMQ backends with the following code:

pip install qiskit_rng
from qiskit_rng import Generator

IBMQ.load_account()
rng_provider = IBMQ.get_provider(hub='ibm-q', group='open', project='main')
backend = rng_provider.backends.ibmq_manila

generator = Generator(backend=backend)
output = generator.sample(num_raw_bits=20001).block_until_ready()
qiskit_raw = output.raw_bits
print(qiskit_raw)

However, I get the following error:

  Input In [3] in <cell line: 2>
    from qiskit_rng import Generator
  File /opt/conda/lib/python3.8/site-packages/qiskit_rng/__init__.py:52 in <module>
    from .generator import Generator
  File /opt/conda/lib/python3.8/site-packages/qiskit_rng/generator.py:35 in <module>
    from qiskit.providers.basebackend import BaseBackend
ModuleNotFoundError: No module named 'qiskit.providers.basebackend'

How can I fix this error? My current version of terra is 0.21.2. Also, is there a way to recreate this process? It is my understanding that IBM uses the GHZ (Greenberger–Horne–Zeilinger) states and then measures them with random X- and Y-measurements. I would appreciate if someone can confirm that.

Thank you!

$\endgroup$

1 Answer 1

1
$\begingroup$

The last qiskit-rng is 0.2.2 from January 2021. It is unmaintained since then and their github repo is archived. Based on their requirements.txt file:

qiskit-ibmq-provider>=0.10
qiskit-terra>=0.16.2

You can get exactly these with:

pip install "qiskit-terra==0.16.2"
pip install "qiskit-ibmq-provider~=0.10"

It should work after that.

$\endgroup$
2
  • $\begingroup$ It does! Thank you! Is there currently a better way implemented by IBM to get some rng? $\endgroup$
    – user22022
    Sep 30, 2022 at 19:15
  • $\begingroup$ Not that I'm aware of. If you have a strong use case for it, I would call the community on slack to consider writing and supporting one. $\endgroup$
    – luciano
    Oct 4, 2022 at 6:20

Your Answer

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

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