module 'google.ads.google_ads.v2.proto.errors' has no attribute 'errors_pb2'

165 views
Skip to first unread message

Yolanda Ou

unread,
Jan 19, 2020, 11:23:39 PM1/19/20
to AdWords API and Google Ads API Forum
Hi, 

I just started to use ads python api as :

When running the code on example, eg, get_keyword_stats.py, I got 
: module 'google.ads.google_ads.v2.proto.errors' has no attribute 'errors_pb2'

How could I fix it?

Many thanks!!

Google Ads API Forum Advisor Prod

unread,
Jan 21, 2020, 3:07:18 PM1/21/20
to yol...@oneflare.com, adwor...@googlegroups.com

Hello,

Thank you for reaching out. This error can be observed as a result of the setup issues. Could you please try to re-download and install the latest version of our Python client libraries from here to remedy setup issues. Please give this a try and let me know if you still run into issues.

Regards,
Nikisha Patel, Google Ads API Team



ref:_00D1U1174p._5001USwqJN:ref

猫头木有鹰

unread,
Feb 24, 2020, 5:10:48 AM2/24/20
to AdWords API and Google Ads API Forum
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/ads/google_ads/interceptors/exception_interceptor.py", line 68, in _get_google_ads_failure
    ga_failure = error_protos.errors_pb2.GoogleAdsFailure()
AttributeError: module 'google.ads.google_ads.v2.proto.errors' has no attribute 'errors_pb2'
 
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/ads/google_ads/interceptors/exception_interceptor.py", line 68, in _get_google_ads_failure
Change like this bellow, then it works!
if trailing_metadata is not None:
for kv in trailing_metadata:
if kv[0] == self._failure_key:
try:
# error_protos = import_module(
# 'google.ads.google_ads.%s.proto.errors' %
# self._api_version)
if self._api_version == 1:
from google.ads.google_ads.v1.proto.errors import errors_pb2
else:
from google.ads.google_ads.v2.proto.errors import errors_pb2
ga_failure = errors_pb2.GoogleAdsFailure()
ga_failure.ParseFromString(kv[1])
return ga_failure
except DecodeError:
return None 

猫头木有鹰

unread,
Feb 24, 2020, 5:26:34 AM2/24/20
to AdWords API and Google Ads API Forum


在 2020年2月24日星期一 UTC+8下午6:10:48,猫头木有鹰写道:
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/ads/google_ads/interceptors/exception_interceptor.py", line 68, in _get_google_ads_failure
    ga_failure = error_protos.errors_pb2.GoogleAdsFailure()
AttributeError: module 'google.ads.google_ads.v2.proto.errors' has no attribute 'errors_pb2'
 
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/ads/google_ads/interceptors/exception_interceptor.py", line 68, in _get_google_ads_failure
Change like this bellow, then it works!

if trailing_metadata is not None:
for kv in trailing_metadata:
if kv[0] == self._failure_key:
try:
                # ↓↓↓↓↓↓↓
errors_pb2 = import_module('google.ads.google_ads.%s.proto.errors.errors_pb2' %self._api_version)
# ↑↑↑↑↑↑↑
                ga_failure = errors_pb2.GoogleAdsFailure()
ga_failure.ParseFromString(kv[1])
return ga_failure
except DecodeError:
return None
return None 

猫头木有鹰

unread,
Feb 24, 2020, 5:26:46 AM2/24/20
to AdWords API and Google Ads API Forum


在 2020年1月20日星期一 UTC+8下午12:23:39,Yolanda Ou写道:

davi...@google.com

unread,
Feb 24, 2020, 7:51:55 AM2/24/20
to AdWords API and Google Ads API Forum
See https://github.com/googleads/google-ads-python/issues/200 for a fix. The GitHub repo is up to date, but PyPi is not as a new major version is coming soon.

Google Ads API Forum Advisor Prod

unread,
Feb 24, 2020, 3:19:34 PM2/24/20
to adwor...@googlegroups.com

Hi,

Thank you for reaching out to us. I would suggest that you see this github post for a fix to the issue, or download and install the latest version of our client library to remedy setup issues. For Google Ads Python, you can find the latest version here. Let me know if you have further questions.

Thank you,
Bryan, Google Ads API Team



ref:_00D1U1174p._5001UXT1uf:ref
Reply all
Reply to author
Forward
0 new messages