Instance of 'Resource' has no 'spreadsheets' member
還沒有人認領這個 Issue。
評估
研究方向
The failing sample is the Google Sheets quickstart script (GSpread.py), and the traceback shows an ImportError for googleapiclient.discovery, so the first check is whether the interpreter VSCode runs has that package installed. The 'Resource has no spreadsheets member' message looks like an editor lint warning rather than a runtime failure. The issue has no linked fix and no agreed change, so it needs a maintainer decision on whether it is a sample bug or an environment question before any edit.
由索引模型根據 Issue 內容生成。
描述
I'm running Quickstart for Google Sheets APIv4 in VSCode and got the following error:
Instance of 'Resource' has no 'spreadsheets' member
and the following output:
[Running] python -u "./GSpread.py"
Traceback (most recent call last):
File "./GSpread.py", line 4, in <module>
from googleapiclient.discovery import build
ImportError: No module named googleapiclient.discovery
[Done] exited with code=1 in 0.092 seconds
Code (Quickstart for Google Sheets APIv4):
from __future__ import print_function
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']
SAMPLE_SPREADSHEET_ID = '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'
SAMPLE_RANGE_NAME = 'Class Data!A2:E'
def main():
creds = None
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES)
creds = flow.run_local_server(port=0)
with open('token.pickle', 'wb') as token:
pickle.dump(creds, token)
service = build('sheets', 'v4', credentials=creds)
sheet = service.spreadsheets()
result = sheet.values().get(spreadsheetId=SAMPLE_SPREADSHEET_ID,
range=SAMPLE_RANGE_NAME).execute()
values = result.get('values', [])
if not values:
print('No data found.')
else:
print('Name, Major:')
for row in values:
print('%s, %s' % (row[0], row[4]))
if __name__ == '__main__':
main()
Tried uninstalling/reinstalling/updating with:
pip3 install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
Environment:
- VSCode version (1.42.1)
- Python version (3.81)
- OS (Mac)
Thanks!
- 主要語言
- Python
- 星號
- 1.4k
- 分支
- 917
- 平均合併
- 3 分鐘
- 30 天內合併 PR
- 1
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
googleworkspace/python-samples 的其他 Issue
-
ايقاف البحث الأمن可能重新可做 @sqrrrl 於 400 天前認領,目前沒有進行中的 PR。 未關閉
googleworkspace/python-samples#2434 · 已指派 1 人 ·
-
Slow Uploads using Google Drive API with Python可能重新可做 @sqrrrl 於 740 天前認領,目前沒有進行中的 PR。 未關閉
googleworkspace/python-samples#1852 · 1 則留言 · 已指派 1 人 ·
-
403 error from google after a few successful runs of my code可能重新可做 @vinay-google 於 912 天前認領,目前沒有進行中的 PR。 未關閉
googleworkspace/python-samples#1424 · 已指派 1 人 ·
-
How to see the progress of files which is getting uploaded可能重新可做 @vinay-google 於 928 天前認領,目前沒有進行中的 PR。 未關閉
googleworkspace/python-samples#1404 · 已指派 1 人 ·
-
Phyton Samples可能重新可做 @PierrickVoulet 於 975 天前認領,目前沒有進行中的 PR。 未關閉
googleworkspace/python-samples#1279 · 已指派 1 人 ·
查看 googleworkspace/python-samples 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 2 天內回覆
-
audit-reference-check
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
site-bug triage
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 77/100
canonical/paas-charm#407 · 1 則留言 ·
維護者通常 5 天內回覆