実現したいこと
google ads apiを使った検索ボリューム自動収集プログラムを作成し、他PCで使うためにexeファイル化する。
問題点
exeファイルを実行させた際、下記のような例外が発生しました。
python
1Traceback (most recent call last): 2 File "keywords_volume.py", line 258, in <module> 3 File "keywords_volume.py", line 70, in main 4 File "google\ads\googleads\client.py", line 358, in get_service 5 File "google\ads\googleads\client.py", line 207, in _get_api_services_by_version 6ValueError: Specified Google Ads API version "v10" does not exist. Valid API versions are: "v10", "v9" 7[6256] Failed to execute script 'keywords_volume' due to unhandled exception!
グーグル翻訳にかけると、
「ValueError:指定されたGoogleAdsAPIバージョン「v10」は存在しません。有効なAPIバージョンは次のとおりです: "v10"、 "v9"
[6256]未処理の例外が原因で、スクリプト'keywords_volume'の実行に失敗しました!」
となります。
指定したバージョンの「v10」は存在しない、という記述と、
有効なAPIバージョンに「v10」がある、という記述が矛盾しているように思えます。
「v10」が有効であれば、なぜ例外処理されているのだろうと頭を悩ませ、かれこれ2時間試行錯誤していますが、一向に解決策が見えません。
exeファイルに変換する前はそのような問題もなく実行できています。
該当のソースコード
python
1@classmethod 2 def _get_api_services_by_version(cls, version): 3 """Returns a module with all services and types for a given API version. 4 5 Args: 6 version: a str indicating the API version. 7 8 Returns: 9 A module containing all services and types for the a API version. 10 """ 11 try: 12 version_module = import_module(f"google.ads.googleads.{version}") 13 except ImportError: 14 raise ValueError( 15 'Specified Google Ads API version "{}" does not ' 16 'exist. Valid API versions are: "{}"'.format( 17 version, '", "'.join(_VALID_API_VERSIONS) 18 ) 19 ) 20 return version_module
自分で調べたこと
pythonファイルである「keywords_volume.py」での実行であれば問題はなく、exeファイルにした際に上記の例外が発生したことから、exeファイルを生成するときに、v10以外の別なフォルダから参照されたのではないかと考えました。
そこで「keywords_volume.py」を動作させるのに必要のないファイルをすべて消して、改めてexeファイル化させましたが、結果は変わらずでした。
ツールのバージョン
python 3.10.4
pyinstaller 5.0.1
https://github.com/googleads/google-ads-python
より
google-ads-python-16.0.0
をもとにプログラム作成。
宜しくお願い致します。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。