gpt4 book ai didi

python-2.7 - httplib2.ServerNotFoundError : Unable to find the server at www. googleapis.com

转载 作者:行者123 更新时间:2023-12-05 04:00:31 26 4
gpt4 key购买 nike

当我尝试使用 google-api (googleapiclient,oauth2client) 获取 gmail 的详细信息时,出现以下错误:

 File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/google_api_python_client-1.7.8-py2.7.egg/googleapiclient/_helpers.py", line 130, in positional_wrapper

File "/usr/local/lib/python2.7/site-packages/google_api_python_client-1.7.8-py2.7.egg/googleapiclient/discovery.py", line 224, in build

File "/usr/local/lib/python2.7/site-packages/google_api_python_client-1.7.8-py2.7.egg/googleapiclient/discovery.py", line 274, in _retrieve_discovery_doc
File "/usr/local/lib/python2.7/site-packages/httplib2-0.12.1-py2.7.egg/httplib2/__init__.py", line 2135, in request
cachekey,
File "/usr/local/lib/python2.7/site-packages/httplib2-0.12.1-py2.7.egg/httplib2/__init__.py", line 1796, in _request
conn, request_uri, method, body, headers
File "/usr/local/lib/python2.7/site-packages/httplib2-0.12.1-py2.7.egg/httplib2/__init__.py", line 1707, in _conn_request

raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
httplib2.ServerNotFoundError: Unable to find the server at www.googleapis.com

但它在我的电脑上工作正常,但在远程位置却不行。

代码:

from googleapiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials

credentials = ServiceAccountCredentials.from_json_keyfile_name(
"quickstart-1551349397232-e8bcb3368ae1.json", scopes=
['https://www.googleapis.com/auth/admin.directory.group', 'https://www.googleapis.com/auth/admin.directory.user', 'https://www.googleapis.com/auth/admin.directory.domain', 'https://www.googleapis.com/auth/gmail.readonly'])

delegated_credentials = credentials.create_delegated('jango@carbonitedepot.com')

DIRECOTORY = build('admin', 'directory_v1', credentials=delegated_credentials)

try:
results = DIRECOTORY.users().list(customer='my_customer').execute()
users = results.get('users', [])
res = []
for info in users:
print(info)
res.append(info.get("primaryEmail"))
print(res)
except Exception as e:
print(e)

如有任何帮助,我们将不胜感激。

提前致谢。

最佳答案

我遇到了同样的问题,我进行了很多搜索以解决它,结果证明我在这里有问题。

我不知道从哪里安装的 podman 而不是 docker 导致了这个问题。

我建议您检查您的 docker 版本并确保最新版本正在服务器上运行,否则,该库可以正常工作!如果您仍然面临这个问题,请告诉我,想深入了解一下!

关于python-2.7 - httplib2.ServerNotFoundError : Unable to find the server at www. googleapis.com,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56147067/

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