前提・実現したいこと
GoogleのAPIを取得し、ドライブへファイルをアップロードするようなプログラムを作成したいのですが、settings.yamlを読み込もうとするとエラーが出てしまいます。settings.yamlはUTF-8で記述しております。
settings.yamlとpythonファイルは同じフォルダに格納しております。
解決法をご教授頂ければ幸いです。
発生している問題・エラーメッセージ
実行するとUnicodeDecodeErrorと言われます。
Traceback (most recent call last): File "/home/pi/APItest/TEST_API.py", line 6, in <module> gauth=GoogleAuth() File "/usr/local/lib/python3.5/dist-packages/pydrive/auth.py", line 169, in __init__ self.settings = LoadSettingsFile(settings_file) File "/usr/local/lib/python3.5/dist-packages/pydrive/settings.py", line 143, in LoadSettingsFile data = load(stream, Loader=Loader) File "/usr/local/lib/python3.5/dist-packages/yaml/__init__.py", line 112, in load loader = Loader(stream) File "/usr/local/lib/python3.5/dist-packages/yaml/loader.py", line 44, in __init__ Reader.__init__(self, stream) File "/usr/local/lib/python3.5/dist-packages/yaml/reader.py", line 85, in __init__ self.determine_encoding() File "/usr/local/lib/python3.5/dist-packages/yaml/reader.py", line 124, in determine_encoding self.update_raw() File "/usr/local/lib/python3.5/dist-packages/yaml/reader.py", line 178, in update_raw data = self.stream.read(size) File "/usr/lib/python3.5/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 126: invalid start byte
該当のソースコード
settings
1client_config_backend: settings 2client_config: 3 client_id: <client_config_backend: settings 4client_config: 5 client_id: <======================> 6 client_secret: <======================> 7 8save_credentials: True 9save_credentials_backend: file 10save_credentials_file: credentials.json 11 12get_refresh_token: True 13 14oauth_scope: 15 - https://www.googleapis.com/auth/drive.file 16 - https://www.googleapis.com/auth/drive.install> 17 client_secret: <===================> 18 19save_credentials: True 20save_credentials_backend: file 21save_credentials_file: credentials.json 22 23get_refresh_token: True 24 25oauth_scope: 26 - https://www.googleapis.com/auth/drive.file 27 - https://www.googleapis.com/auth/drive.install
python
1from pydrive.auth import GoogleAuth 2from pydrive.drive import GoogleDrive 3import json 4import datetime 5 6gauth = GoogleAuth() 7gauth.CommandLineAuth() 8drive = GoogleDrive(gauth) 9 10f=drive.CreateFile({'title':'TEST.TXT'}) 11f.SetContentString('Hello')
補足情報(FW/ツールのバージョンなど)
python3
OS:Raspbian
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/26 11:02
2019/03/26 11:21