我想在Windows上用Python3进行谷歌搜索。谷歌的说明称他们支持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")
我理解为:
[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