gpt4 book ai didi

python - 模块未找到错误 : No module named 'google.appengine'

转载 作者:太空狗 更新时间:2023-10-29 21:30:19 25 4
gpt4 key购买 nike

我想在 Windows 上用 python3 进行谷歌搜索。谷歌说明说他们支持 python3 并键入“gcloud topic init”以获取详细信息 - 但没有说 python2.7 没有解释器。我是否必须安装 python2.7 才能了解如何让它在 python3 上运行?

在 python3 上,我收到如下错误消息。我已经设置了一个 API key 和一个自定义搜索引擎。我做了“pip install google-api-python-client”。我下载并运行了 GoogleCloudSDKInstaller。这是错误:

from googleapiclient.discovery import build
service = build("customsearch", "v1", developerKey="xxxxxx")

我得到:

[googleapiclient.discovery_cache:WARNING]:file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth (__init__.py:44, time=Apr-07 17:25) Traceback (most recent call last):   File "C:\Users\simon\Anaconda3\lib\site-packages\googleapiclient\discovery_cache\__init__.py", line 36, in autodetect
from google.appengine.api import memcache ModuleNotFoundError: No module named 'google.appengine'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\simon\Anaconda3\lib\site-packages\googleapiclient\discovery_cache\file_cache.py", line 33, in <module>
from oauth2client.contrib.locked_file import LockedFile ModuleNotFoundError: No module named 'oauth2client'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\simon\Anaconda3\lib\site-packages\googleapiclient\discovery_cache\file_cache.py", line 37, in <module>
from oauth2client.locked_file import LockedFile ModuleNotFoundError: No module named 'oauth2client'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\simon\Anaconda3\lib\site-packages\googleapiclient\discovery_cache\__init__.py", line 41, in autodetect
from . import file_cache File "C:\Users\simon\Anaconda3\lib\site-packages\googleapiclient\discovery_cache\file_cache.py", line 41, in <module>
'file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth') ImportError: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth [googleapiclient.discovery:INFO]:URL being requested: GET https://www.googleapis.com/discovery/v1/apis/customsearch/v1/rest?key=AIzaSyBGDtIo_P8xXbn0ksb15wUhy6sdR_eBDpU

最佳答案

创建服务时需要参数cache_discovery=False,如下:

service = discovery.build('customsearch', 'v1', credentials=<...>, cache_discovery=False)

关于python - 模块未找到错误 : No module named 'google.appengine' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55561354/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com