Divya
Divya

Reputation: 339

module 'numpy' has no attribute 'object'

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

Upvotes: 32

Views: 133058

Answers (5)

Talha Tayyab
Talha Tayyab

Reputation: 27385

Instead of numpy.object:

you should use object or numpy.object_.

OR

import numpy as np
np.object = np.object_

Upvotes: 3

Vegarus
Vegarus

Reputation: 480

Try to use simple "monkey path". Add line like

np.object = object    

or

np.int = int    

in case module 'numpy' has no attribute 'int'

np.float = float    

module 'numpy' has no attribute 'int'

np.bool = bool    

and so on... (if problem with last Numpy versions)

Upvotes: 9

Keval
Keval

Reputation: 773

Try :

pip3 install numpy==1.23.5

I was facing same issue with numpy 1.24.2

Upvotes: 15

Jan
Jan

Reputation: 675

Since version 1.24 of numpy, np.object is deprecated, and needs to be replaced with object (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 with pip install numpy==1.23.4

Upvotes: 37

Veera Nagireddy
Veera Nagireddy

Reputation: 1888

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 the numpy module. To solve the error, make sure to rename any local files named numpy.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 called numpy.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.

Upvotes: -3

Related Questions