Gspread 不再能够访问谷歌表格

时间:2021-04-03 18:48:37

标签: python gspread

我一直在使用 Gspread 和 df2gspread 将提取的值从数据帧写入谷歌表。它一直工作到大约一周前,没有对会影响可访问性的代码进行任何更改(据我所知)。我现在收到一个运行时错误,即 Google 表格不存在或无法访问。我已经仔细检查了来自 Google API 管理器的所有凭据。

scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']
gsheet_id = '*************************'
sheet_name = 'Item Price'
credentials = ServiceAccountCredentials.from_json_keyfile_name(
    'C:/Users/PC/AppData/Roaming/JetBrains/PyCharm2020.2/scratches/BDO_Creds_Service.json', scope)  # Your json file here
gc = gspread.authorize(credentials)
item_prices = g2d.download(gfile=gsheet_id, wks_name='Item Price', col_names=True, row_names=False, credentials=credentials)
Traceback (most recent call last):
  File "C:\Users\PC\PycharmProjects\BDOScraper\venv\lib\site-packages\IPython\core\interactiveshell.py", line 3417, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-b8d3e089e2e5>", line 1, in <module>
    runfile('C:/Users/PC/AppData/Roaming/JetBrains/PyCharm2020.2/scratches/BDO Prices.py', wdir='C:/Users/PC/AppData/Roaming/JetBrains/PyCharm2020.2/scratches')
  File "C:\Program Files\JetBrains\PyCharm 2020.2.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm 2020.2.3\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/PC/AppData/Roaming/JetBrains/PyCharm2020.2/scratches/BDO Prices.py", line 194, in <module>
    item_prices = import_sheet_data()
  File "C:/Users/PC/AppData/Roaming/JetBrains/PyCharm2020.2/scratches/BDO Prices.py", line 59, in import_sheet_data
    item_prices = g2d.download(gfile=gsheet_id, wks_name='Item Price', col_names=True, row_names=False,
  File "C:\Users\PC\PycharmProjects\BDOScraper\venv\lib\site-packages\df2gspread\gspread2df.py", line 79, in download
    raise RuntimeError(
RuntimeError: Trying to open non-existent or inaccessible worksheet

0 个答案:

没有答案
相关问题