【问题标题】:Pydrive auth not working httplib.ResponseNotReadyPydrive 身份验证不起作用 httplib.ResponseNotReady
【发布时间】:2020-11-05 03:09:29
【问题描述】:

我正在尝试使用 python 将文件发送到谷歌驱动器,但我被卡在了身份验证部分。
当我运行下面的代码时,谷歌的网页正确打开,我可以选择我的帐户,它给了我祝贺消息:“身份验证流程已完成。”。

import os
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from requests.auth import HTTPBasicAuth

#Then we authenticate to google
print("debug-2")
g_login = GoogleAuth()
print("debug-1")
g_login.LocalWebserverAuth()
print("debug0")
drive = GoogleDrive(g_login)

#And we send the file
print("debug1")
with open("test.txt","r") as file:
    print("debug2")
    file_drive = drive.CreateFile({'title':os.path.basename(file.name) })  
    file_drive.SetContentString(file.read())
    file1_drive.Upload()
print("debug3")

看起来不错,但在我的 shell 中,代码卡在“debug-1”,好像“LocalWebserverAuth()”从未工作过。此外,我的驱动器中仍然没有文件,因此上传确实无法正常工作,而不仅仅是“视觉卡住”。

这是 shell 中的消息:

当我让它自行结束时,我得到一个 python 错误:httplib.ResponseNotReady.
欢迎任何想法!

更新: 连接问题。我的是没有使用代理造成的。

【问题讨论】:

    标签: python oauth-2.0 google-drive-api google-authentication pydrive


    【解决方案1】:

    此错误的根本原因可能与您的 firewall/antivirus 阻止传入/传出连接有关。尝试禁用它,看看它是否能解决问题。

    您可能还会看到其他解决方案here

    【讨论】:

    • 我已经看到了这个,这也是我的结论,但希望我能找到其他东西......无论如何谢谢你!
    • @Bruuuh 恐怕没有其他解决方案了。
    • 你是对的,我改变了代理,它终于可以正常工作了!谢谢
    猜你喜欢
    • 1970-01-01
    • 2012-10-04
    • 1970-01-01
    • 2012-04-29
    • 2012-03-18
    • 2011-07-05
    • 2013-12-02
    相关资源
    最近更新 更多