ModuleNotFoundError:没有名为“ google.appengine”的模块

sim*_*mon 13 python google-app-engine google-search-api python-3.x google-custom-search

我想在Windows上的python3中进行Google搜索。谷歌的说明说,他们支持python3并键入“ gcloud topic init”以获取详细信息-但这未能说明没有python2.7的解释器。我是否必须安装python2.7才能了解如何使其在python3上正常工作?

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

from googleapiclient.discovery import build
service = build("customsearch", "v1", developerKey="xxxxxx")
Run Code Online (Sandbox Code Playgroud)

我得到:

[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
Run Code Online (Sandbox Code Playgroud)

sim*_*mon 22

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

service = discovery.build('customsearch', 'v1', credentials=<...>, cache_discovery=False)
Run Code Online (Sandbox Code Playgroud)

  • 知道为什么会很棒?仅遵循[quickstart](https://developers.google.com/drive/api/v3/quickstart/python)指南对我来说会导致错误 (3认同)
  • @Rob,我正在挖掘相同的问题,并且似乎缓存系统中的代码路径已损坏。您可以在[这些](https://github.com/googleapis/google-api-python-client/issues/345)中看到[问题](https://github.com/googleapis/google-api-python- client / issues / 299)的更多信息,但似乎在oauth2client&gt; 4.0.0时缓存无法正常工作 (3认同)