inspyred library, collections 에

Model fitting 하기 위해 evolutionary algorithm 을 사용해야하는 상황이 있어서 오랜만에 inspyred를 다시 세팅했는데, 아래 에러가 난다.

attribute error: module ‘collections’ has no attribute ‘iterator’

이 문제는 python 버젼 3.10 부터 collections 밑에 iterator가 바로 있는 것이 아니라 collections.abc 밑으로 들어갔기 떄문에 발생한다.

가장 좋은 방법은 라이브러리가 업데이트 되는 건데.. 업데이트가 일단 안되고 있는 오래된 라이브러리라 패스.

두번째는 파이썬 버젼을 3.9 대로 내리는 방법이다. 다른 디펜던시 때문에 패스.

마지막으로는 그냥 inspyred library에서 해당 부분을 고쳐 쓰는것. 라이브러리가 활발하게 업데이트 되는 상황이면 이런 선택은 안하겠지만…. 오래된 거라

inspyred/ec/ec.py 파일을 수정하면 되고 26번 라인에

import collections

이 부분을 아래와 같이 수정

import collections.abc as collections

잘 됨


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *