garret

[Python] import gluonnlp error 본문

Error

[Python] import gluonnlp error

_Sun_ 2024. 6. 25. 16:58

에러메세지

AttributeError: module 'numpy' has no attribute 'bool'.

 

 

 

코랩에서 KoBERT에서 필요한 라이브러리 중 하나인 gluonnlp를 불러오다가 생긴 에러. 

처음에는 이슈원인을 못 찾다가 아래 글에서 힌트를 얻어서 해결했다.

 

https://stackoverflow.com/questions/74893742/how-to-solve-attributeerror-module-numpy-has-no-attribute-bool

 

How to solve AttributeError: module 'numpy' has no attribute 'bool'?

I'm using a conda environment with Python version 3.9.7, pip 22.3.1, numpy 1.24.0, gluoncv 0.10.5.post0, mxnet 1.7.0.post2 from gluoncv import data, utils gives the error: C:\Users\std\anaconda3\e...

stackoverflow.com

 

 

이슈 해결과정

 

코랩 python 3.10에는 numpy 1.25.1이 설치되어 있다.

numpy 1.25.1은 이전버전에는 있었던 numpy.bool이 삭제된 것으로 보인다. 

최신 gluonnlp 라이브러리에서 numpy.bool이 사용되고 있어 생기는 오류로 보임.

 

numpy 1.23.1로 다운그레이드 하거나, python을 3.8로 세팅해야 할 듯하다.

 

나의 경우 numpy를 1.23.1으로 다운그레이드하여 이슈를 해결했다.

pip uninstall numpy

pip install numpy==1.23.1

 

 

 

이슈 close.

 

koBERT가 생긴지는 몇 년 됐는데 더이상 관리가 되고 있지 않다보니, 환경세팅부터 신경써야할 것이 은근 많은 것 같다.

코랩은 세팅이 자동으로 돼서 사용이 편하다는 장점이 있지만, 이렇게 라이브러리 버전이 중요한 모델을 쓸 때는 매번 환경세팅을 다시 해줘야 하는게 또 단점인듯.