当前位置:  开发笔记 > 编程语言 > 正文

Python SSL错误解密失败或错误记录mac

如何解决《PythonSSL错误解密失败或错误记录mac》经验,为你挑选了0个好方法。

我正在尝试使用gspread python模块来阅读谷歌电子表格.但是我从ssl得到了一些错误.我试图调查这个,但无法使它工作.gspread模块在内部使用python请求,似乎是使用python的ssl包.代码(我已经写过)和堆栈跟踪在下面提供了env详细信息.

ENV:

python:2.7.13

Ubuntu:14.04

openssl:1.0.1f 2014年1月6日

码:

import gspread
from oauth2client.client import SignedJwtAssertionCredentials

scope = ['https://spreadsheets.google.com/feeds']
credentials = SignedJwtAssertionCredentials(user_email, private_key, scope)
google_client = gspread.authorize(credentials)


worksheet = google_client.open_by_url().get_worksheet(1)

list_of_rows = worksheet.get_all_values()

print list_of_rows

堆栈跟踪:

File "", line 1, in 
  File "/home/nikhil/.venv/nikhil/src/gspread/gspread/models.py", line 344, in get_all_values
    cells = self._fetch_cells()
  File "/home/nikhil/.venv/nikhil/src/gspread/gspread/models.py", line 231, in _fetch_cells
    feed = self.client.get_cells_feed(self)
  File "/home/nikhil/.venv/nikhil/src/gspread/gspread/client.py", line 186, in get_cells_feed
    r = self.session.get(url)
  File "/home/nikhil/.venv/nikhil/src/gspread/gspread/httpsession.py", line 76, in get
    return self.request('GET', url, **kwargs)
  File "/home/nikhil/.venv/nikhil/src/gspread/gspread/httpsession.py", line 68, in request
    response = func(url, data=data, headers=request_headers, verify=False)
  File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/sessions.py", line 469, in get
    return self.request('GET', url, **kwargs)
  File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/sessions.py", line 457, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/sessions.py", line 606, in send
    r.content
  File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/models.py", line 724, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/models.py", line 653, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/packages/urllib3/response.py", line 256, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/home/nikhil/.venv/nikhil/lib/python2.7/site-packages/requests/packages/urllib3/response.py", line 186, in read
    data = self._fp.read(amt)
  File "/usr/local/lib/python2.7.13/lib/python2.7/httplib.py", line 573, in read
    return self._read_chunked(amt)
  File "/usr/local/lib/python2.7.13/lib/python2.7/httplib.py", line 642, in _read_chunked
    value.append(self._safe_read(chunk_left))
  File "/usr/local/lib/python2.7.13/lib/python2.7/httplib.py", line 688, in _safe_read
    chunk = self.fp.read(min(amt, MAXAMOUNT))
  File "/usr/local/lib/python2.7.13/lib/python2.7/socket.py", line 384, in read
    data = self._sock.recv(left)
  File "/usr/local/lib/python2.7.13/lib/python2.7/ssl.py", line 766, in recv
    return self.read(buflen)
  File "/usr/local/lib/python2.7.13/lib/python2.7/ssl.py", line 653, in read
    v = self._sslobj.read(len)
SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:1864)

任何帮助将非常感激.

更新: 我已在新机器上从头开始设置所有内容,并且还更新了oauth客户端以使用新的API版本.无法使上述环境工作,所以暂时保持这个问题.

推荐阅读
手机用户2402852387
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有