반응형

<Hist>

[2023-10-19] 생성

 

<Note>

발생되는 과정은 불명이나, Protobuf v3.20.0 이후로 Python Class가 단순화되었기 때문이라고 합니다.

이러한 부분이 최신으로 패치되지 않거나, 구버전의 코드가 잔류하면 발생하는 오류인 것으로 판단됩니다.

자세한 내용은 아래의 내용을 참고해주세요!

 

▶ Ref. https://stackoverflow.com/a/71984564

"The reason is that the Python classes are simplified since Protobuf v3.20.0. Straight from the release notes it says:

Protobuf python generated codes are simplified. Descriptors and message classes' definitions are now dynamic created in internal/builder.py. Insertion Points for messages classes are discarded.

This explains why the generated Python code now refers to a builder module, which it cannot find if you haven't updated to the latest version of the protobuf package. This is not explained in the release notes, but I verified myself that it works if you upgrade the protobuf package."

 

"그 이유는 Protobuf v3.20.0 이후로 Python 클래스가 단순화되었기 때문입니다. 릴리스 노트에서 바로 다음과 같이 나와 있습니다: 

python에서 생성된 코드의 프로토타입이 단순화되었습니다. 이제 descriptor와 메시지 클래스의 정의는 internal/builder.py 에서 동적으로 생성됩니다. 메시지 클래스의 삽입 지점은 삭제됩니다.

이것은 이제 생성된 파이썬 코드가 최신 버전의 프로토오브패키지를 업데이트하지 않았다면 찾을 수 없는 빌드 모듈을 의미하는 이유를 설명합니다. 릴리즈 노트에는 설명되어 있지 않지만 프로토오브패키지를 업그레이드하면 작동한다는 것을 스스로 확인했습니다."

 

Fig 01. 오류 발생

■ 원인

발생되는 과정은 불명이나, 
1) pip update 등으로 최신화되지 않거나, 구버전의 코드가 잔류하면 발생

2) 또는 최신 코드의 호환성 오류

등으로 예상

 

■ 현상

Fig 01과 같이, TF Module을 동작할 수 없다.

 

■ 조치

01) protobuf 검색하여 위치 파악

       Error Code에서 나타나는 경로는 주로

       "C:\Users\[사용자명]\anaconda3\Lib\site-packages\google\protobuf\__init__.py"이나,

      실제로 조치해야하는 파일은

       "C:\Users\[사용자명]\anaconda3\Lib\site-packages\google\protobuf\internal\builder.py"

      이다.

 

      그러나 설치된 경로를 찾을 수 없다면, anaconda prompt에서 아래와 같은 명령어를 입력하여 위치를 찾을 수 있다.

      (작업 전 미리 백업 권장)

       <Command>

       pip show protobuf

Fig 02. Anaconda Prompt를 통한 protobuf 설치 경로 확인

 

Fig 03. 해당 Directory 내 site-packages/google/protobuf/internal/builder.py를 확인할 수 있다.

02) protobuf 최신으로 업데이트

       anaconda prompt나 jupyter 등을 통해 protobuf를 최신으로 업데이트

       <Command>

       pip install --upgrade protobuf

03) 최신버전의 Builder.py 복사

04) protobuf를 다운그레이드

       anaconda prompt나 jupyter 등을 통해 protobuf를 다운그레이드 (삭제 후 재설치)

       <Command>

       pip uninstall

       pip install protobuf==3.19.4

05) 복사해둔 최신 버전의 builder.py를 덮어씌우기

Fig 04. Code가 제대로 동작하는 것을 볼 수 있다.

 

반응형
LIST

+ Recent posts