在windows桌面上试用PyDrive



我正在学习如何使用PyDrive库

我在....PycharmProjectsQtvenvLibsite-packages上安装了PyDrive我复制了代码并将其保存在c:usersmetest.py

现在我被困在如何运行它。我有谷歌驱动器帐户已经存储了一些文件。

我需要简单的步骤来从命令提示符或Idle或PyCharm运行它我需要谷歌云账户还是其他什么?

我改为(venv)c:\user\me\test.py

我得到

ERROR  File "..PycharmProjectsQtvenvlibsite-packagesoauth2clientclientsecrets.py", line 121, in _loadfile
with open(filename, 'r') as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'client_secrets.json'
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gauth = GoogleAuth()
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)
file1 = drive.CreateFile({'title': 'Hello.txt'})
file1.SetContentString('Hello')
file1.Upload() 

docsfile.GetContentFile('test.html', mimetype='text/html')

PyDrive已弃用,取而代之的是PyDrive2(pip install PyDrive2)

所有Google SDK都需要一个auth令牌,您可以参考关于如何生成一个以及在哪里创建JSON文件(在您的工作目录中)的文档,该文件由库读取

此外,请务必阅读Google Drive Python API官方页面

最新更新