gspread:SSLError:python中的[SSL:CERTIFICATE_VERIFY_FAILED]

时间:2016-01-12 15:55:00

标签: python gspread

我有几行代码,直到今天才使用得非常好(使用gspread)。每当我运行此代码时,我都会收到证书验证错误:

json_key = json.load(open('Sheetmodification_abc.json'))
scope = ['https://spreadsheets.google.com/feeds']

credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'].encode(), scope)

gc = gspread.authorize(credentials)

wks = gc.open("googlespreadsheets").sheet1

这可能是什么原因以及如何解决?我一直在寻找解决方案:https://github.com/burnash/gspread/issues/223

但是不明白所提供的解决方案。

编辑:这是追溯:

---------------------------------------------------------------------------
SSLError                                  Traceback (most recent call last)
C:\Users\Nathan\App_Finder_2.0.1.py in <module>()
    142     gc = gspread.authorize(credentials)
    143 
--> 144     wks = gc.open("googlespreadsheets").sheet1
    145 
    146     # 1. Retrieve app name

C:\Users\Nathan\AppData\Local\Enthought\Canopy\User\lib\site-packages\gspread\client.pyc in open(self, title)
    143 
    144         """
--> 145         feed = self.get_spreadsheets_feed()
    146 
    147         for elem in feed.findall(_ns('entry')):

C:\Users\Nathan\AppData\Local\Enthought\Canopy\User\lib\site-packages\gspread\client.pyc in get_spreadsheets_feed(self, visibility, projection)
    229                             visibility=visibility, projection=projection)
    230 
--> 231         r = self.session.get(url)
    232         return ElementTree.fromstring(r.content)
    233 

C:\Users\Nathan\AppData\Local\Enthought\Canopy\User\lib\site-packages\gspread\httpsession.pyc in get(self, url, **kwargs)
     73 
     74     def get(self, url, **kwargs):
---> 75         return self.request('GET', url, **kwargs)
     76 
     77     def delete(self, url, **kwargs):

C:\Users\Nathan\AppData\Local\Enthought\Canopy\User\lib\site-packages\gspread\httpsession.pyc in request(self, method, url, data, headers)
     65         except AttributeError:
     66             raise Exception("HTTP method '{}' is not supported".format(method))
---> 67         response = func(url, data=data, headers=request_headers)
     68 
     69         if response.status_code > 399:

C:\Users\Nathan\AppData\Local\Enthought\Canopy\User\lib\site-packages\requests\api.pyc in get(url, params, **kwargs)
     67 
     68     kwargs.setdefault('allow_redirects', True)
---> 69     return request('get', url, params=params, **kwargs)
     70 
     71 

C:\Users\Nathan\AppData\Local\Enthought\Canopy\User\lib\site-packages\requests\api.pyc in request(method, url, **kwargs)
     48 
     49     session = sessions.Session()
---> 50     response = session.request(method=method, url=url, **kwargs)
     51     # By explicitly closing the session, we avoid leaving sockets open which
     52     # can trigger a ResourceWarning in some cases, and look like a memory leak

C:\Users\Nathan\AppData\Local\Enthought\Canopy\User\lib\site-packages\requests\sessions.pyc in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    463         }
    464         send_kwargs.update(settings)
--> 465         resp = self.send(prep, **send_kwargs)
    466 
    467         return resp

C:\Users\Nathan\AppData\Local\Enthought\Canopy\User\lib\site-packages\requests\sessions.pyc in send(self, request, **kwargs)
    571 
    572         # Send the request
--> 573         r = adapter.send(request, **kwargs)
    574 
    575         # Total elapsed time of the request (approximately)

C:\Users\Nathan\AppData\Local\Enthought\Canopy\User\lib\site-packages\requests\adapters.pyc in send(self, request, stream, timeout, verify, cert, proxies)
    429         except (_SSLError, _HTTPError) as e:
    430             if isinstance(e, _SSLError):
--> 431                 raise SSLError(e, request=request)
    432             elif isinstance(e, ReadTimeoutError):
    433                 raise ReadTimeout(e, request=request)

SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)

0 个答案:

没有答案