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
解决方案
推荐阅读
- python - AttributeError:“_io.TextIOWrapper”对象没有属性“rpartition”
- reactjs - 为什么我的本地存储在页面刷新后没有保存
- python - 神经网络攻击傻瓜(FGSM)
- microsoft-graph-api - 通过 msgraph 搜索 Sharepoint 列表和文档
- java - 如何根据选择的主题显示不同的启动画面?
- php - 在 Laravel 中生成上传视频的缩略图
- vb.net - 动态文本框颜色变化
- java - Kd 树级顺序遍历
- fortran - 使用 OpenMP 并行的矩阵乘法不会提高执行时间
- java - 可以在 ANT 任务的类路径中引用 Spring Boot jar 中的类吗?