1

我想上传一个存在于树莓派文件夹中的文本文件。为此,我使用了以下代码:

from pydrive.drive import GoogleDrive
drive = GoogleDrive(gauth)

file1 = drive.CreateFile({'title': 'Hello.txt'})  # Create GoogleDriveFile instance with title 'Hello.txt'.
file1.SetContentString('Hello World!') # Set content of the file from given string.
file1.Upload()

在树莓派中运行此代码我收到以下错误:

 Traceback (most recent call last):   File "uploadfile3.py", line 1, in <module>
    from pydrive.drive import GoogleDrive   File "/usr/local/lib/python2.7/dist-packages/pydrive/drive.py", line 2, in <module>
    from .files import GoogleDriveFile   File "/usr/local/lib/python2.7/dist-packages/pydrive/files.py", line 12, in <module>
    from .auth import LoadAuth   File "/usr/local/lib/python2.7/dist-packages/pydrive/auth.py", line 9, in <module>
    from oauth2client.service_account import ServiceAccountCredentials   File "/usr/local/lib/python2.7/dist-packages/oauth2client/service_account.py", line 26, in <module>
    from oauth2client import crypt   File "/usr/local/lib/python2.7/dist-packages/oauth2client/crypt.py", line 23, in <module>
    from oauth2client import _pure_python_crypt   File "/usr/local/lib/python2.7/dist-packages/oauth2client/_pure_python_crypt.py", line 24, in <module>
    from pyasn1_modules.rfc2459 import Certificate   File "/usr/local/lib/python2.7/dist-packages/pyasn1_modules/rfc2459.py", line 20, in <module>
    from pyasn1.type import opentype ImportError: cannot import name opentype

请帮助我消除此错误。如果还有其他方法可以上传文本文件,请帮我解决。

4

1 回答 1

2

请参阅https://github.com/etingof/pyasn1-modules/issues/10,我怀疑这与 oauth2client 的弃用以及 2017 年 11 月 23 日 pyasn1 和 pyasn1-modules 的发布有关。

于 2017-11-27T20:35:25.703 回答