使用 tools.run_flow() 在 Google Sheets API 教程中引发 SSLHandshake "certificate verify" 错误

Using tools.run_flow() raises SSLHandshake "certificate verify" error in Google Sheets API tutorial

我非常关注 Google 表格的入门(在 Python 中)。我已经让程序在我的 Mac 笔记本电脑上运行,但它失败了,因为我试图在 Windows 上 运行 它。到目前为止,我已经检查过我们没有在机器上启用防火墙。

以下是点击浏览器中弹出的身份验证提示后出现的错误。

Traceback (most recent call last):
  File "Authenticate.py", line 47, in <module>
    main()
  File "Authenticate.py", line 43, in main
    tools.run_flow(flow, store)
  File "C:\johnsnow\packages\test\lib\site-packages\oauth2client\_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\johnsnow\packages\test\lib\site-packages\oauth2client\tools.py", line 243, in run_flow
    credential = flow.step2_exchange(code, http=http)
  File "C:\johnsnow\packages\test\lib\site-packages\oauth2client\_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\johnsnow\packages\test\lib\site-packages\oauth2client\client.py", line 2054, in step2_exchange
    http, self.token_uri, method='POST', body=body, headers=headers)
  File "C:\johnsnow\packages\test\lib\site-packages\oauth2client\transport.py", line 282, in request
    connection_type=connection_type)
  File "C:\johnsnow\packages\test\lib\site-packages\httplib2\__init__.py", line 1570, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "C:\johnsnow\packages\test\lib\site-packages\httplib2\__init__.py", line 1317, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "C:\johnsnow\packages\test\lib\site-packages\httplib2\__init__.py", line 1252, in _conn_request
    conn.connect()
  File "C:\johnsnow\packages\test\lib\site-packages\httplib2\__init__.py", line 1044, in connect
    raise SSLHandshakeError(e)
httplib2.SSLHandshakeError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)

我不太确定这是怎么发生的,因为我在 virtualenv 中工作,但是 httplib2 和 oauth2 的版本存在依赖性问题。卸载后重新安装,出现两个库不兼容的错误。

执行 pip freeze 表明我有 httplib2==0.8 但需要 oauth2client httplib2=>0.9.

这已通过 pip install --upgrade httplib2 解决。