Search code examples
pythongoogle-colaboratorygspread

AttributeError: module 'gspread' has no attribute 'service_account'


I am trying to access a spreadsheet from Colaboratory using the gspread library, but get the attribute error module 'gspread' has no attribute 'service_account'

My code looks like this:

import gspread as gs
import pandas as pd
gc = gs.service_account(filename='[link_to_the_service_account_json_file]')
sh = gc.open_by_url('[link_to_the_sheet]')
ws = sh.worksheet('[sheetname]')
df = pd.DataFrame(ws.get_all_records())
df.head()

What am I doing wrong?


Solution

  • service_account() was added in version 3.6 and I was using 3.4.2

    https://github.com/burnash/gspread/releases/tag/v3.6.0