Registry / gcp / gsheets

gsheets

JSON →
library0.6.1pypypi✓ verified 84d ago

Pythonic wrapper for the Google Sheets API (v4). Current version 0.6.1, requires Python >=3.7. Low release cadence.

pip install gsheets
INSTALL
IMPORT
SIG · GSHEETS
G
gsheets
gcppythonv0.6.1
Install
5.3s avg
Import
1333ms
Disk
146MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.374s · 146.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.3s · import 1.292s · 147MB
146MB installed
● package 146MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SheetsManager
from gsheets import Sheets
from gsheets import SheetsManager
Old class name; SheetsManager was renamed to Sheets in v0.3
Sheets
from gsheets import Sheets

Initialize with OAuth client secret file, then access spreadsheet by key.

from gsheets import Sheets sheets = Sheets.from_files('client_secret.json', 'storage.json') # Or via environment variable for CI: import os sheets = Sheets.from_files(os.environ.get('GSHEETS_CLIENT_SECRET', 'client_secret.json'), os.environ.get('GSHEETS_STORAGE', 'storage.json')) sheet = sheets['<SPREADSHEET_KEY>'] print(sheet.title)
Debug
Known issues
gotchaThe library uses oauth2client (deprecated). For new projects, consider switching to google-auth directly.
fix
Use google-auth and google-api-python-client with manual credentials.
affects: all
deprecatedSheetsManager was renamed to Sheets in v0.3. Importing SheetsManager will break.
fix
Use 'from gsheets import Sheets' instead.
affects: >=0.3
gotchaSpreadsheet keys are case-sensitive and must be the full ID from URL, not the URL itself.
fix
Extract the key from the URL: https://docs.google.com/spreadsheets/d/<KEY>/edit
affects: all
gotchaRows returned are 1-indexed and include header row by default. The first data row is row 2.
fix
Use sheet.to_frame(head=1) to skip header if using pandas.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'SheetsManager' from 'gsheets'
SheetsManager was renamed to Sheets in v0.3.
fix
Change import to 'from gsheets import Sheets'
AttributeError: 'Sheets' object has no attribute 'from_files'
Using an older version (<0.3) that didn't have the class-based API.
fix
Upgrade to latest: pip install --upgrade gsheets
google.auth.exceptions.RefreshError: invalid_grant
OAuth token expired or client_secret.json is incorrect.
fix
Delete storage.json and re-authenticate, or regenerate client_secret.json from Google Cloud Console.
Upgrade
Version history
0.6.1latest on PyPI · released Jun 12, 2022
Audit
Dependencies
google-api-python-clientrequiredRequired for Google Sheets API authentication and client
oauth2clientrequiredUsed for OAuth2 authentication (deprecated in favor of google-auth)
Agent activity
41 hits · last 30 days
node
36
OpenAI (training)
1
Resources
gsheets — pip install gsheets · libregistry