下記1のコードに対して、下記2のエラーが発生します。エラーコードを元に海外のサイトなども見合わせてみましたが、Anacondaが原因だろうというところまでたどり着いたのですが、根本的な原因がわからずじまいです。解決法を知っている方いらっしゃいましたら、シェアの方よろしくお願いいたします。
下記(実行コード)
import os
import gspread
from oauth2client.service_account import
ServiceAccountCredentials
def main():
scope = ['https://spreadsheets.google.com/feeds']
doc_id = 'Your doc id'
path = os.path.expanduser("Path of json file")
credentials = ServiceAccountCredentials.from_json_keyfile_name(path, scope)
client = gspread.authorize(credentials)
gfile = client.open_by_key(doc_id)
worksheet = gfile.sheet1
records = worksheet.get_all_values()
for record in records:
print(record)
if __name__ == '__main__':
main()
下記2(エラー)
Traceback (most recent call last):
File "/Users/user/flilhack/\u540d\u79f0\u672a\u8a2d\u5b9a\u30d5\u30a9\u30eb\u30bf\u3099/tes.py", line 20, in <module>
main()
File "/Users/user/flilhack/\u540d\u79f0\u672a\u8a2d\u5b9a\u30d5\u30a9\u30eb\u30bf\u3099/tes.py", line 13, in main
worksheet = gfile.sheet1
File "/Users/user/anaconda3/lib/python3.6/site-packages/gspread/v4/models.py", line 75, in sheet1
return self.get_worksheet(0)
File "/Users/user/anaconda3/lib/python3.6/site-packages/gspread/v4/models.py", line 138, in get_worksheet
sheet_data = self.fetch_sheet_metadata()
File "/Users/user/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/user/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/user/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "/Users/user/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/Users/user/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/Users/user/anaconda3/lib/python3.6/site-packages/requests/adapters.py", line 407, in send
self.cert_verify(conn, request.url, verify, cert)
File "/Users/user/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/user/anaconda3/lib/python3.6/site-packages/certifi/cacert.pem
[Finished in 0.641s]
使用環境
Mac10.13.3 Python3