1

我想从我的Windows桌面使用gspread和python写入电子表格。以下代码适用于我的Mac笔记本电脑,但在PC上运行时,我收到一个SSLHandshakeError。我已经确定必要的文件可用于程序,并尝试创建没有运气的新项目,我总是得到相同的错误。SSLHandshakeError证书验证失败

下面是代码:

#databaseTest.py 
import sys 
import os 
import pyodbc 
import json, gspread 
from oauth2client.client import SignedJwtAssertionCredentials 

json_key = json.load(open('H:\MyProject-ee653db0fe92.json')) 
scope = ['https://spreadsheets.google.com/feeds', 'https://docs.google.com/feeds'] 
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope) 
print "Authorizing..." 
try: 
    gc = gspread.authorize(credentials) 
    input("Done") 
except: 
    print "SSL error" 
    input("Something went wrong") 
    gspread.authorize(credentials) 

这里是错误,我得到的最后一部分:

File "C:\Python27\lib\site-packages\httplib2\__init__.py", line 1059, in connect 
raise SSLHandshakeError(e) 
httplib2.SSLHandshakeError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) 

回答

0

事实证明,与连接到电子表格从桌面上的问题是由它所连接的网络引起。笔记本电脑连接到不同的网络,这使得它可以与电子表格进行通信,但是台式机的网络有许多防火墙和安全措施阻止了这一点。

相关问题