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

事實證明,與連接到電子表格從桌面上的問題是由它所連接的網絡引起。筆記本電腦連接到不同的網絡,這使得它可以與電子表格進行通信,但是臺式機的網絡有許多防火牆和安全措施阻止了這一點。

相關問題