본문 바로가기
python

python AttributeError: module 'numpy' has no attribute 'complex'

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

python 앱 실행 시 발생한 에러

python app. py

Traceback (most recent call last):
 File "\librosa\core\constantq.py", line 1059, in <module>
dtype=np.complex,

File "\numpy\__init__.py", in _getattr_
 raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'complex'.
'np. complex' was a deprecated alias for the builtin 'complex'.
To avoid this error in existing code, use 'complex' by itself.
Doing this will not modify any behavior and is safe.
If you specifically wanted the numpy scalar type
, use 'np.complex128' 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: 'complex64'?
에러 메시지

에러 메시지에서 .complex가 사용된 코드를 찾습니다.

(예시에서는 dtype=np.complex 이 코드는 사용자마다 다를 수 있습니다)

.complex 코드를 찾은 후 코드 바로 윗줄에 있는 파일을 메모장으로 엽니다.

(예시에서는 ...\librosa\core\ 경로에 있는 constantq.py 파일)

메모장에서 해당 파일을 열고 Ctrl+G 키를 누르고 에러 메시지에 적힌 줄로 이동합니다.

(예시에서는 1059번째 줄)

 

에러 메시지에 적힌 링크 ↓

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

 

메모장 - constantq.py
줄로 이동
줄 번호
1059
이동
메모장 줄 이동
메모장 - constantq.py

dtype=np.complex
np.complex 찾기

complex가 사용된 곳으로 바로 이동됩니다.

(예시에서는 dtype=np.complex)

 

메모장 - constantq.py

dtype=np.complex128
수정

기존 np.complexnp.complex128 또는 complex로 수정합니다.

 

메모장 - constantq.py
파일 → 저장
저장

저장한 후 메모장을 종료합니다.

 

python app.py
config.json: 100%
다시 실행

python 앱을 다시 실행해 보면 실행이 잘 됨을 알 수 있습니다.

반응형

댓글