Python Forum
Linking python to Google Sheets - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Linking python to Google Sheets (/thread-19646.html)



Linking python to Google Sheets - Charliefish1311 - Jul-08-2019

When trying to link python with this code

import gspread
from oauth2client.service_account import ServiceAccountCredentials

from pprint import pprint

scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]

creds = ServiceAccountCredentials.from_json_keyfile_name("client_secret.json", scope)

client = gspread.authorize(creds)

sheet = client.open("Cohort 2020 Teacher Assessment").sheet1  # Open the spreadhseet
This error code appears

Error:
Traceback (most recent call last): File "C:\Users\charl\Desktop\Cohort 2020 Folder\spreadsheets.py", line 10, in <module> client = gspread.authorize(creds) File "C:\Users\charl\AppData\Local\Programs\Python\Python37-32\lib\site-packages\gspread\__init__.py", line 38, in authorize client.login() File "C:\Users\charl\AppData\Local\Programs\Python\Python37-32\lib\site-packages\gspread\client.py", line 51, in login self.auth.refresh(http) File "C:\Users\charl\AppData\Local\Programs\Python\Python37-32\lib\site-packages\oauth2client\client.py", line 545, in refresh self._refresh(http) File "C:\Users\charl\AppData\Local\Programs\Python\Python37-32\lib\site-packages\oauth2client\client.py", line 749, in _refresh self._do_refresh_request(http) File "C:\Users\charl\AppData\Local\Programs\Python\Python37-32\lib\site-packages\oauth2client\client.py", line 780, in _do_refresh_request body=body, headers=headers) File "C:\Users\charl\AppData\Local\Programs\Python\Python37-32\lib\site-packages\oauth2client\transport.py", line 282, in request connection_type=connection_type) File "C:\Users\charl\AppData\Local\Programs\Python\Python37-32\lib\site-packages\httplib2\__init__.py", line 1953, in request cachekey, File "C:\Users\charl\AppData\Local\Programs\Python\Python37-32\lib\site-packages\httplib2\__init__.py", line 1618, in _request conn, request_uri, method, body, headers File "C:\Users\charl\AppData\Local\Programs\Python\Python37-32\lib\site-packages\httplib2\__init__.py", line 1524, in _conn_request conn.connect() File "C:\Users\charl\AppData\Local\Programs\Python\Python37-32\lib\site-packages\httplib2\__init__.py", line 1307, in connect self.sock = self._context.wrap_socket(sock, server_hostname=self.host) File "C:\Users\charl\AppData\Local\Programs\Python\Python37-32\lib\ssl.py", line 412, in wrap_socket session=session File "C:\Users\charl\AppData\Local\Programs\Python\Python37-32\lib\ssl.py", line 853, in _create self.do_handshake() File "C:\Users\charl\AppData\Local\Programs\Python\Python37-32\lib\ssl.py", line 1117, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
any ideas on how to fix this, i have tried installing the latest gspread and oauth2client however still no hope


RE: Linking python to Google Sheets - micseydel - Jul-09-2019

What makes you think that code will work? If you're following a tutorial, please post the link here.