{"library":"pygsheets","title":"Pygsheets: Google Spreadsheets Python API v4","description":"Pygsheets is a simple, intuitive Python library that provides an interface to the Google Sheets API v4. It enables programmatic interaction with Google Spreadsheets, allowing users to create, open, edit, and share spreadsheets, as well as manage worksheets, cells, and ranges. The library supports advanced features like conditional formatting, data validation, and batch operations. The current version is 2.0.6, and it maintains an active development cycle with regular updates and bug fixes.","language":"python","status":"active","last_verified":"Thu May 14","install":{"commands":["pip install pygsheets"],"cli":null},"imports":["import pygsheets"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pygsheets\nimport os\n\n# Ensure your service account JSON key file is present and its path is in an environment variable\n# Instructions to get one: https://pygsheets.readthedocs.io/en/latest/authorization.html#service-account\nservice_file_path = os.environ.get('PYGSHEETS_SERVICE_ACCOUNT_FILE', 'path/to/your/service_account.json')\n\nif not os.path.exists(service_file_path) or service_file_path == 'path/to/your/service_account.json':\n    print(f\"Warning: Service account file not found at '{service_file_path}'. Please set PYGSHEETS_SERVICE_ACCOUNT_FILE environment variable or update the path.\")\n    print(\"Cannot run quickstart without valid service account credentials.\")\nelse:\n    try:\n        # Authorize with service account credentials\n        gc = pygsheets.authorize(service_account_file=service_file_path)\n\n        # Open a spreadsheet by name or create it if it doesn't exist\n        spreadsheet_name = \"My Test Spreadsheet\"\n        try:\n            sh = gc.open(spreadsheet_name)\n            print(f\"Opened existing spreadsheet: {spreadsheet_name}\")\n        except pygsheets.exceptions.SpreadsheetNotFound:\n            sh = gc.create(spreadsheet_name)\n            # Share with your Google account if you want to see it in your Drive\n            # sh.share('your-email@example.com', role='writer', type='user')\n            print(f\"Created new spreadsheet: {spreadsheet_name}\")\n\n        # Select the first worksheet\n        wks = sh[0]\n\n        # Update a cell\n        wks.update_value('A1', 'Hello from pygsheets!')\n        print(f\"Updated cell A1 in '{spreadsheet_name}' with 'Hello from pygsheets!'\")\n\n        # Get a value\n        cell_value = wks.get_value('A1')\n        print(f\"Value in A1: {cell_value}\")\n\n        # Update a range of values\n        data = [[1, 2, 3], [4, 5, 6]]\n        wks.update_values('B2', data)\n        print(f\"Updated range B2:D3 with: {data}\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to authorize `pygsheets` using a service account, open or create a Google Sheet, and perform basic operations like updating and retrieving cell values. Remember to set up a Google Cloud Project, enable the Google Sheets API and Google Drive API, create a service account, and download its JSON key file. The path to this file should be provided via the `PYGSHEETS_SERVICE_ACCOUNT_FILE` environment variable for secure credential handling.","tag":null,"tag_description":null,"last_tested":"2026-04-25","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-14","installed_version":"2.0.6","pypi_latest":"2.0.6","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":5.2,"avg_import_s":1.86,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pygsheets","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":1.61,"mem_mb":24.4,"disk_size":"147.8M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pygsheets","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":1.84,"mem_mb":24.3,"disk_size":"146.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pygsheets","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":5.5,"import_time_s":1.19,"mem_mb":24.4,"disk_size":"149M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pygsheets","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":1.26,"mem_mb":24.3,"disk_size":"147M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pygsheets","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.87,"mem_mb":26.8,"disk_size":"152.1M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pygsheets","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":2.22,"mem_mb":26.6,"disk_size":"150.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pygsheets","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":5.1,"import_time_s":1.68,"mem_mb":26.8,"disk_size":"153M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pygsheets","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":2,"mem_mb":26.6,"disk_size":"151M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pygsheets","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.99,"mem_mb":26.5,"disk_size":"143.5M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pygsheets","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":2.26,"mem_mb":26.3,"disk_size":"142.1M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pygsheets","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":4.6,"import_time_s":1.99,"mem_mb":26.5,"disk_size":"144M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pygsheets","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":2.5,"mem_mb":26.3,"disk_size":"143M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pygsheets","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.93,"mem_mb":27.6,"disk_size":"143.3M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pygsheets","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":2.16,"mem_mb":27.4,"disk_size":"141.7M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pygsheets","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":4.5,"import_time_s":1.9,"mem_mb":27.6,"disk_size":"144M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pygsheets","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":2.83,"mem_mb":27.4,"disk_size":"142M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pygsheets","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":1.43,"mem_mb":24.1,"disk_size":"147.8M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pygsheets","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":1.61,"mem_mb":24,"disk_size":"146.4M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pygsheets","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":6.3,"import_time_s":1.38,"mem_mb":24.1,"disk_size":"149M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pygsheets","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":1.61,"mem_mb":24,"disk_size":"147M"}]}}