본문 바로가기
python

python 앱 AttributeError: module 'numpy' has no attribute 'float'

by 젤리아드 2024. 12. 27.
반응형

python 앱 구동 중 발생한 에러

File "\librosa\util\utils.py", Line 869, in normalize
mag = np.abs(S). astype(np.float64)
File "\numpy\__init__.py", line 394, in __getattr__
raise AttributeError(__former_attrs__[attr])
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.
Did you mean: 'float16'?
에러 메시지

일단 에러 메시지에서 float이 쓰인 파일을 찾습니다.

(위 예시에서는 ...\librosa\util\utils.py 파일의 869번째 줄에서 에러 발생)

에러가 발생한 파일을 메모장으로 엽니다.

 

에러 메시지에 적힌 링크↓

https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations.

 

NumPy 1.20.0 Release Notes — NumPy v2.3.dev0 Manual

NumPy 1.20.0 Release Notes This NumPy release is the largest so made to date, some 684 PRs contributed by 184 people have been merged. See the list of highlights below for more details. The Python versions supported for this release are 3.7-3.9, support fo

numpy.org

 

메모장 - utils.py

줄로 이동
줄 번호
869

이동, 취소
줄 이동

에러가 난 파일을 메모장으로 연 후 Ctrl+G키를 눌러서 에러가 발생한 줄로 이동합니다.

(위 예시에서는 869번째 줄)

 

메모장 - utils.py
float 수정
수정

에러가 발생한 줄로 이동하면 float이 쓰인 곳을 찾을 수 있습니다.

기존 np.floatnp.float64 또는 float으로 수정합니다.

수정 후 메모장을 저장하고 종료합니다.

에러가 난 python 앱을 종료하고 다시 실행해 봅니다.

반응형

댓글