#python #python-3.x
Вопрос:
from oauth2client.service_account import ServiceAccountCredentials
import gspread
scope = ['https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('key.json', scope)
client = gspread.authorize(credentials)
worksheet = client.open("PM").sheet1
res = worksheet.get_all_records()
print(res)
Ошибка
Traceback (most recent call last):
File "F:Arul FilesPythonEXEmain.py", line 10, in <module>
credentials = ServiceAccountCredentials.from_json_keyfile_name('key.json', scope)
File "F:Arul FilesPythonvenvlibsite-packagesoauth2clientservice_account.py", line 219, in from_json_keyfile_name
with open(filename, 'r') as file_obj:
FileNotFoundError: [Errno 2] No such file or directory: 'key.json'
Комментарии:
1. Попробуйте указать абсолютный путь к «ключу.json».