Python3でサーバ時刻と現在時刻のずれで発生すると思われるエラーを解決したい
発生しているエラーメッセージ
Traceback (most recent call last):
File "/Users/username/flilhack/\u540d\u79f0\u672a\u8a2d\u5b9a\u30d5\u30a9\u30eb\u30bf\u3099/tes.py", line 27, in <module>
print(get_spreadsheet_data())
File "/Users/username/flilhack/\u540d\u79f0\u672a\u8a2d\u5b9a\u30d5\u30a9\u30eb\u30bf\u3099/tes.py", line 23, in get_spreadsheet_data
wsheet = gfile.get_worksheet(0)
File "/Users/username/anaconda3/lib/python3.6/site-packages/gspread/v4/models.py", line 138, in get_worksheet
sheet_data = self.fetch_sheet_metadata()
File "/Users/username/anaconda3/lib/python3.6/site-packages/gspread/v4/models.py", line 120, in fetch_sheet_metadata
r = self.client.request('get', url, params=params)
File "/Users/username/anaconda3/lib/python3.6/site-packages/gspread/v4/client.py", line 67, in request
endpoint, json=json, params=params, data=data, files=files
File "/Users/username/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "/Users/username/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/Users/username/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/Users/username/anaconda3/lib/python3.6/site-packages/requests/adapters.py", line 407, in send
self.cert_verify(conn, request.url, verify, cert)
File "/Users/username/anaconda3/lib/python3.6/site-packages/requests/adapters.py", line 226, in cert_verify
"invalid path: {0}".format(cert_loc))
OSError: Could not find a suitable TLS CA certificate bundle, invalid path: /Users/username/anaconda3/lib/python3.6/site-packages/certifi/cacert.pem
[Finished in 0.597s]
tes.py26:1
LFUTF-8Python0 files3 updates
oauth2client.client.HttpAccessTokenRefreshError
該当のソースコード(Python3)
import gspread
from oauth2client.service_account import ServiceAccountCredentials
def get_spreadsheet_data():
doc_id = '[spreadsheet URL のid]'
json_key_path = '/Users/username/Downloads/My Project-a5bcde8be455.json'
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name(json_key_path, scope)
gclient = gspread.authorize(credentials)
gfile = gclient.open_by_key(doc_id)
wsheet = gfile.get_worksheet(0)
records = wsheet.get_all_records(head=1)
return records
print(get_spreadsheet_data())
試したこと
似たようなエラーがないかを確認したところ、スタックオーバーフローの本家の方で時刻のズレが原因ということを発見いたしました。わたしは現在Mac10.13.3を使用しており、日付と時刻の環境設定から自動設定にて設定しております. 手動設定なども試しましたが解決には至りませんでした。
使用環境
- OS Mac10.13.3
- Python3
- Atom