【发布时间】:2021-04-23 14:57:43
【问题描述】:
我正在尝试将 Python Jupyter 刮板脚本(和 json cred 文件)从我的笔记本电脑移动到 Google Colab。 我已经在 Google Colab 和 Google Drive 之间建立了连接。 我已将 (.ipynb) 脚本和凭据 JSON 文件存储在 Google Drive 上。 但是我无法在 2(gdrive json cred 文件和 colab)之间建立连接以使其工作。 下面是有关凭据处理的脚本部分:
# Sheet key
# 1i1bmMt-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_d7Eo
import gspread
import pandas as pd
import requests
from bs4 import BeautifulSoup
from oauth2client.service_account import ServiceAccountCredentials
# Access credentials for google sheet and access the google sheet
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"]
# Copy your path to your credential JSON file.
PATH_TO_CREDENTIAL = '/Users/user/json-keys/client_secret.json'
# Initiate your credential
credentials = ServiceAccountCredentials.from_json_keyfile_name(PATH_TO_CREDENTIAL, scope)
# Authorize your connection to your google sheet
gc = gspread.authorize(credentials)
我收到 FileNotFoundError: 和凭据错误 希望有人能帮帮我,谢谢
【问题讨论】:
标签: python google-sheets google-drive-api google-colaboratory google-codelab