close

[Solved] Can´t import qiskit, attribute error in numpy: “ ‘numpy.random’ has no attribute ‘default_rng’”

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Can´t import qiskit, attribute error in numpy: “ ‘numpy.random’ has no attribute ‘default_rng’” in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Can´t import qiskit, attribute error in numpy: “ ‘numpy.random’ has no attribute ‘default_rng’” Error Occurs?

Today I get the following error Can´t import qiskit, attribute error in numpy: “ ‘numpy.random’ has no attribute ‘default_rng’” in Python.

How To Solve Can´t import qiskit, attribute error in numpy: “ ‘numpy.random’ has no attribute ‘default_rng’” Error ?

  1. How To Solve Can´t import qiskit, attribute error in numpy: “ 'numpy.random' has no attribute 'default_rng'” Error ?

    To Solve Can´t import qiskit, attribute error in numpy: “ 'numpy.random' has no attribute 'default_rng'” Error You need NumPy 1.17 or later to have the new RNG functions that Qiskit needs

  2. Can´t import qiskit, attribute error in numpy: “ 'numpy.random' has no attribute 'default_rng'”

    To Solve Can´t import qiskit, attribute error in numpy: “ 'numpy.random' has no attribute 'default_rng'” Error You need NumPy 1.17 or later to have the new RNG functions that Qiskit needs

Solution 1

I got almost the same error as:

AttributeError: module ‘numpy.random’ has no attribute ‘default_rng’

with the numpy version of '1.16.2'

numpy.__version__
'1.16.2'

As a solution, either you need to put these lines at the top of your file:

import numpy
numpy.random.bit_generator = numpy.random._bit_generator

Or the your current numpy version probably is <= 1.17. Hence, you need to update the NumPy version. For instance, I have updated it on Anaconda environment as:

conda update numpy

And the current version is:

numpy.__version__
'1.19.2'

Updates take time because of lots of dependencies of NumPy. Hopefully, the issue is resolved on my side!

Solution 2

You need NumPy 1.17 or later to have the new RNG functions that Qiskit needs

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment