我正试图用python将一个文件发送到google驱动器,但我在某种程度上陷入了困境。
当我运行下面的代码,从谷歌打开的网页正确,我可以选择我的帐户,它给我祝贺信息:“认证流已完成.”。
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中,代码被卡在“"LocalWebserverAuth()”调试-1“上,就好像从未工作过一样。此外,在我的驱动器仍然没有文件,所以上传是真的不工作,而不仅仅是“视觉卡住”。
下面是shell中的消息:

当我让它自行结束时,我会得到一个python错误:httplib.ResponseNotReady。
任何想法都欢迎!
更新:连接问题。我是因为不使用代理而造成的。
发布于 2020-07-15 21:33:49
此错误的根本原因可能与firewall/antivirus阻塞传入/传出连接有关。试着禁用它,看看它是否解决了问题。
您可能还会看到其他解决方案这里。
https://stackoverflow.com/questions/62917914
复制相似问题