새소식

💬 ALL

[python error] googletrans라이브러리, 호환문제, httpx충돌

  • -

 

<googletrans 라이브러리>

1. AttributeError: 'NoneType' object has no attribute 'group'

2. AttributeError: module 'httpcore' has no attribute 'SyncHTTPTransport'

 

 

문제1.  googletrans AttributeError: 'NoneType' object has no attribute 'group'

AttributeError: 'NoneType' 개체에 'group' 속성이 없습니다.
 

 

번역기 API를 사용해서 프로그램 비교를 하다가 파이썬 googletrans 라이브러리 사용중 에러가 떴습니다.

에러명 : AttributeError: 'NoneType' object has no attribute 'group'

이때 버전 변경 및 pip 삭제 및 재설치해주면 해결된다.

해결

pip uninstall googletrans

삭제 후 터미널에서 googletrans 버전을 사용하여 리스트 뽑아준다.

pip install googletrans==5

저는 openai 라이브러리와 버전을 맞추기 위해 3.1.0a0버전을 사용하였습니다.

pip install googletrans==3.1.0a0
pip install googletrans

 

 

문제 2. googletrans AttributeError: module 'httpcore' has no attribute 'SyncHTTPTransport' 싱크해결

위 문제를 해결 후 구글번역기 파이썬파일을 실행했을때 발생, 즉 실행이 안되었습니다.

이 문제는 openai 1.3.7에는 httpx=0.23.0이 필요하지만 호환되지 않는 httpx0.13.3이 있는 버전오류였다.

 

해결

수정 해야할 파일 위치 
/가상환경폴더이름/lib/python3.11/site-packages/googletrans/cient.py
예시 - /ch07_env/lib/python3.11/site-packages/googletrans/client.py

vscode 작업 중인 파이썬 가상환경 내 위 경로를 따라가면 client.py라는 파일이 있습니다.

이 파일을 수정해야합니다.

 

63번줄의 httpcore.SyncHTTPTransport -> httpcore.AsyncHTTPProxy로 변경하면 해결됩니다.

 

아래의 링크를 참고하여 작성되었습니다.

 

AttributeError: module 'httpcore' has no attribute 'SyncHTTPTransport

While importing googletrans I am getting this error: AttributeError: module 'httpcore' has no attribute 'SyncHTTPTransport

stackoverflow.com

 

Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.