I recently started coding in Python. In the beginning of my scripts I always have the following import: import numpy as np.
In one of my scripts, I use np.matlib.repmat function. It used to work ok, however recently it fails to run showing the following error:
 AttributeError: module 'numpy' has no attribute 'matlib'
I searched SO for this problem, and it looks like the error like this arises if one has a script called numpy.py in his working directory or if the installed version is different and does not contain the called module.
I didn't name any file numpy.py. I also found out that after I call:
 from numpy import matlib as mb
I can use mb.repmat. Therefore, my numpy module does contain matlib module.
Can someone hint me, why I cannot call np.matlib?
This was already answer here.
This is because
numpy.matlibis an optional sub-package ofnumpythat must be imported separately. When you import justnumpywithout the sub-packagematlib, then Python will be looking for.matlibas an attribute of thenumpypackage. This attribute has not been assigned tonumpywithout importing numpy.matlib
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With