我按照本参考指南的步骤尝试安装adwords api for python:https://github.com/googleads/googleads-python-lib/wiki/API-access-using-own-credentials-(installed-application-flow)#step-2---setting-up-the-client-library
一切都还可以,但在最后一步(6)中,我遇到了一个问题。
我尝试运行代码:
from googleads import adwords
# Initialize the AdWords client.
adwords_client = adwords.AdWordsClient.LoadFromStorage()
错误是:
> >pythonw -u "teste_adwords_api.py" Traceback (most recent call last): File "teste_adwords_api.py", line 3, in <module>
> adwords_client = adwords.AdWordsClient.LoadFromStorage() File "C:\Users\Flávio\Google Drive\BI Caiçara\Python\googleads\adwords.py",
> line 243, in LoadFromStorage
> cls._OPTIONAL_INIT_VALUES)) File "C:\Users\Flávio\Google Drive\BI Caiçara\Python\googleads\common.py", line 128, in
> LoadFromStorage
> 'Given yaml file, %s, could not be opened.' % path) googleads.errors.GoogleAdsValueError: Given yaml file,
> C:\Users\Flávio\googleads.yaml, could not be opened.
我的googleads.yaml是:
adwords:
client_id: xxxxxxx
client_secret: xxxxxx
refresh_token: xxxxxx
其中xxxx是我的密码密钥
我无法理解安装过程中出现的问题。
答案 0 :(得分:7)
遇到过类似的问题。 默认情况下,它会在主目录中搜索googleads.yaml文件,您可以在创建AdWords客户端时将其指向您的位置,例如,
adwords_client = AdWordsClient.LoadFromStorage("full_path_to_your_googleads.yaml")
例如:
adwords_client=AdWordsClient.LoadFromStorage(""C:\\MacUSer\\Documents\\googleads.yaml")
希望这能解决它。
答案 1 :(得分:0)
yaml文件是否存在于C:\ Users \Flávio\或其他路径中?在将yaml文件复制到Users \之前,我遇到了同样的错误。&lt;