0

I am trying to read data from Google Sheets. I get error:

Traceback (most recent call last):
  File "C:\Users\terterya\AppData\Local\Programs\Python\Python37\lib\site-packages\gspread\client.py", line 121, in open
    self.list_spreadsheet_files(title),
  File "C:\Users\terterya\AppData\Local\Programs\Python\Python37\lib\site-packages\gspread\utils.py", line 97, in finditem
    return next((item for item in seq if func(item)))


During handling of the above exception, another exception occurred:
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".\myScript.py", line 14, in <module>
    sheet = client.open('https://docs.google.com/spreadsheets/d/1Eo8QGzdwaiF7m59Tro1oN8ewfktDBI0KLfF3UL87lTk/edit?usp=sharing')
  File "C:\Users\terterya\AppData\Local\Programs\Python\Python37\lib\site-packages\gspread\client.py", line 129, in open
    raise SpreadsheetNotFound
gspread.exceptions.SpreadsheetNotFound

Here is my code:

import pandas
import gspread
from oauth2client.service_account import ServiceAccountCredentials

# define the scope
scope = ['https://spreadsheets.google.com/feeds','https://www.googleapis.com/auth/drive']

# add credentials to the account
creds = ServiceAccountCredentials.from_json_keyfile_name(r'C:\Users\terterya\Desktop\Google_Sheets\My_First_Project-911240f50418.json', scope)

# authorize the clientsheet
client = gspread.authorize(creds)

sheet = client.open('https://docs.google.com/spreadsheets/d/1Eo8QGzdwaiF7m59Tro1oN8ewfktDBI0KLfF3UL87lTk/edit?usp=sharing')

I have provided access to the Google Sheet to my Google Service Account:

enter image description here

I get the URL from "Copy link" button, so it is shareable link. I know about gspread.exceptions.SpreadsheetNotFound.

How can I debug this?

halfer
  • 19,824
  • 17
  • 99
  • 186

0 Answers0