首页 > 解决方案 > 在 Windows 桌面上试用 PyDrive

问题描述

我正在关注这个来学习如何使用 PyDrive 库

我在复制代码时安装了 PyDrive ....PycharmProjects\Qt\venv\Lib\site-packages 并将其保存在 c:\users\me\test.py

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

我需要简单的步骤从命令提示符或 Idle 或 PyCharm 运行它我需要 Google 云帐户或其他任何东西吗?

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

我明白了

ERROR  File "..\PycharmProjects\Qt\venv\lib\site-packages\oauth2client\clientsecrets.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')

标签: pythonpydrive

解决方案


PyDrive不推荐使用PyDrive2( pip install PyDrive2)

所有 Google SDK 都需要一个身份验证令牌,您可以参考文档,了解如何生成一个以及在哪里创建库读取的 JSON 文件(在您的工作目录中)

还请务必阅读官方的 Google Drive Python API 页面


推荐阅读