The error “AttributeError: module ‘numpy’ has no attribute ‘random'” can occur when you try to use the “random” submodule of the NumPy library, but it cannot be found. Here are some possible solutions:
Check if you have installed NumPy correctly. You can do this by opening a Python shell and running import numpy. If you see no errors, then NumPy is installed properly.
Check if you are importing NumPy correctly. Make sure you are importing the entire NumPy library by using import numpy, and not just a specific submodule like from numpy import random.
Check if you have a variable named “numpy” in your code. If you have defined a variable with the name “numpy”, it could be overriding the NumPy library and causing the error. Try renaming the variable to something else.
Check if you have multiple versions of NumPy installed. If you have multiple versions of NumPy installed, it could be causing a conflict. Try uninstalling all versions of NumPy and then reinstalling the latest version.
Upgrade NumPy to the latest version. You can do this by running pip install –upgrade numpy in your terminal or command prompt.
If none of these solutions work, please provide more information about your code and the specific error message, so that we can help you better.