IT/Programming

[Python] A load persistent id instruction was encountered,but no persistent_load function was specified. 해결

이녀기 2023. 7. 2. 13:12

문제 상황

with open(f"./{dir_name}/agents/{id_code}", "rb") as file:
	saving_list.append(pickle.load(file))
Exception has occurred: UnpicklingError
A load persistent id instruction was encountered, but no persistent_load function was specified.

.pickle로 저장해둔 object를 불러오려 했는데, 에러가 발생했다.

 

해결

확장자에 주의한다!(.pickle)

코드를 수정하다가 .pickle이란 확장자를 지우고 파일 이름까지만 작성해둬서 파일이 제대로 인식되지 않은 것 같다. '.pickle' 이란 확장자를 명확히 기술하는 것으로 해결했다.

with open(f"./{dir_name}/agents/{id_code}.pickle", "rb") as file:
	saving_list.append(pickle.load(file))

 

참고자료

https://hyen4110.tistory.com/135

 

[Error] A load persistent id instruction was encountered

딥러닝 모델 예측 파일 실행하는데 아래와 같은 에러가 발생 A load persistent id instruction was encountered but no persistent\_load function was specified. 살펴보니, .bin 파일을 pickle로 load해서 발생했음 (이전에 작

hyen4110.tistory.com