I am getting below error when running mlflow app
raise AttributeError("module {!r} has no attribute " AttributeError:
module ‘numpy’ has no attribute ‘object’
Can someone help me with this
I am getting below error when running mlflow app
raise AttributeError("module {!r} has no attribute " AttributeError:
module ‘numpy’ has no attribute ‘object’
Can someone help me with this
5
Answers
The Python "AttributeError module ‘numpy’ has no attribute ‘object’" occurs when we have a local file named
numpy.py
and try to import it from thenumpy
module. To solve the error, make sure to rename any local files namednumpy.py
.Another way: Check that the file you are running was named
numpy.py
. If you have this problem check to make sure you don’t have a file in the directory callednumpy.py
.In most cases,
rename your project local file numpy.py and delete numpy.pyc if it exists
, then your project file script will run without an attribute error.Easy way to check is to move the file with the import statement to a different directory and try running it.
Please check whether you have installed a newer pip updated numpy version.
Also check the similar SO for more information.
This error sometime occurs when an older version of numpy is been imported by other package, which does not have the ‘object’ attribute on it.
You can try the following:
Solution 1:
pip install --upgrade numpy
Solution 2: Re-install numpy
Solution 3 (if you are using conda package manager):
conda update numpy
Last but not least, in case if you are running multiple version of python on your machine, you have to check which version of python your MLflow is using.
You can check that by running
which python
in command line and then make sure that the required version ofnumpy
is installed.Since version 1.24 of numpy,
np.object
is deprecated, and needs to be replaced withobject
(cf. numpy release notes).You either need to update this in your code, or another package you’re using needs to be updated (not possible to answer without more information).
One (dirty) workaround for now would be to fix your numpy version to the last version still supporting
np.object
withpip install numpy==1.23.4
Try :
I was facing same issue with numpy 1.24.2
Try to use simple "monkey path". Add line like
or
in case module ‘numpy’ has no attribute ‘int’
module ‘numpy’ has no attribute ‘int’
and so on… (if problem with last Numpy versions)