Python Forum

Full Version: Linking python to Google Sheets
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
What makes you think that code will work? If you're following a tutorial, please post the link here.