0

When i try to install nibabel lirary i get an error like this. Tried different version of numpy and didn't work out. Any idea how to solve this?

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-954ce44cd9c4> in <module>
----> 1 import nibabel as nb
      2 import matplotlib.pyplot as plt
      3 import numpy as np
      4 import sys

3 frames
/usr/local/lib/python3.9/dist-packages/numpy/__init__.py in __getattr__(attr)
    303 
    304         if attr in __former_attrs__:
--> 305             raise AttributeError(__former_attrs__[attr])
    306 
    307         # Importing Tester requires importing all of UnitTest which is not a

AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

To get an solution for an error i am facing.

  • Do you have the latest version of `nibabel` (5.0.1 Fed 2033 according to the github repository)? They should have corrected this deprecation issue by now. If it still is a problem, raise an issue at its repository. Downgrading your numpy (from 1.24) should remove the error, but not the warning. – hpaulj Mar 27 '23 at 16:05
  • I changed the np.float to float in source file and it worked. – O-Negative Mar 28 '23 at 02:46
  • Please provide enough code so others can better understand or reproduce the problem. – Community Mar 28 '23 at 03:46
  • error appeared in this line /usr/local/lib/python3.9/dist-packages/nibabel/quaternions.py in 29 import numpy as np 30 ---> 31 MAX_FLOAT = np.maximum_sctype(np.float) 32 FLOAT_EPS = np.finfo(np.float).eps 33 so i went to /usr/local/lib/python3.9/dist-packages/nibabel/quaternions.py and changed the np.float to float in source file then it worked. – O-Negative Mar 28 '23 at 04:03
  • Also problem appears to be happaning when we use TPU as our backend engine. – O-Negative Mar 28 '23 at 04:04

1 Answers1

0

This is a version incompatibility in your environment. This bug was fixed in https://github.com/nipy/nibabel/pull/964, which was included in the 3.2.1 release.

To resolve this, you either need to upgrade nibabel or downgrade numpy.