python - 在 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')
解决方案
PyDrive
不推荐使用PyDrive2
( pip install PyDrive2
)
所有 Google SDK 都需要一个身份验证令牌,您可以参考文档,了解如何生成一个以及在哪里创建库读取的 JSON 文件(在您的工作目录中)
推荐阅读
- angular - 如果表格有任何变化,我需要倾听,如果有变化,请启用/禁用“保存”按钮 | 角
- reactjs - 使用基于反应的前端损坏文件从 expressjs 服务器下载音频文件
- reactjs - 样式化的组件默认道具值没有被拾取
- authentication - Task scheduler involves running programs which need login
- amazon-web-services - How to consume Amazon S3 objects from Flink?
- python - Python递归函数,在if语句中返回
- reactjs - The delete function of firebase
- c# - 如何在 IdentityServer4 中创建像 Google、AAD 这样的自定义外部登录?
- python - 如何根据条件将信号连接到不同的插槽
- matlab - 为什么 inv(matrix)*matrix 不是 Octave 中的精确单位矩阵?