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

pip install qiskit_rng
from qiskit_rng import Generator

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

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!


1 Answer 1


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:


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.

  • $\begingroup$ It does! Thank you! Is there currently a better way implemented by IBM to get some rng? $\endgroup$
    – user22022
    Commented 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
    Commented Oct 4, 2022 at 6:20

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.