본문 바로가기
Python

[Google Analytics Data API] ModuleNotFoundError: No module named 'google.analytics'

by guru_k 2022. 5. 9.
728x90
반응형
SMALL

python을 통한 google analytics data API 호출 시 아래와 같은 에러가 발생

ModuleNotFoundError: No module named 'google.analytics'

해당 에러는 python에 필요한 package가 설치되어 있지 않아서 발생하는 것으로 pip를 통해 google-analytics-data package를 설치 해 준다.

https://github.com/googleapis/python-analytics-data#installation

 

GitHub - googleapis/python-analytics-data

Contribute to googleapis/python-analytics-data development by creating an account on GitHub.

github.com

Mac/Linux

pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install google-analytics-data

Windows

pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install google-analytics-data

Test

$ python3 ga.py

Report result: metadata {
  currency_code: "USD"
  time_zone: "Asia/Seoul"
}
kind: "analyticsData#runReport"

 

728x90
반응형
LIST

댓글0