[英]Python: PermissionError: [Errno 13] Permission denied with pydrive?
Here's my code for a very simple program:这是我的一个非常简单的程序的代码:
import os, shutil
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
source_path = r"c:/users/x/appdata/roaming/medianxl/save"
destination_path = r"c:/users/x/desktop/backup_saves"
print("Contents being backed up:")
print(os.listdir(source_path))
destination = shutil.copytree(source_path, destination_path)
print("Contents successfully backed up to:", destination_path)
print("Now uploading backup saves to Google Drive...")
auth = GoogleAuth()
auth.LocalWebserverAuth()
drive = GoogleDrive(auth)
saves = drive.CreateFile()
saves.SetContentFile(r"c:/users/x/desktop/backup_saves")
saves.Upload()
So far I am having no issues when it comes to taking the folder from the appdata location and copying it to my desktop.到目前为止,从 appdata 位置获取文件夹并将其复制到我的桌面时,我没有任何问题。 Where I am getting the error in my title is when I go to upload that folder and its contents on my desktop to Google Drive using pydrive.
我在标题中遇到错误的地方是当我 go 使用 pydrive 将该文件夹及其在我的桌面上的内容上传到 Google Drive 时。
Here's the output from the command window after running the program:这是运行程序后来自命令 window 的 output :
Contents being backed up:
['preferences.json', 'TSW', 'uhp_prettycolor.d2s', 'uhp_prettycolor.key', 'uhp_prettycolor.ma0', 'uhp_prettycolor.map']
Contents successfully backed up to: c:/users/x/desktop/backup_saves
Now uploading backup saves to Google Drive...
Your browser has been opened to visit:
url here
Authentication successful.
Traceback (most recent call last):
File "backup.py", line 21, in <module>
saves.SetContentFile(r"c:/users/x/desktop/backup_saves")
File "C:\Users\x\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pydrive\files.py", line 169, in SetContentFile
self.content = open(filename, 'rb')
PermissionError: [Errno 13] Permission denied: 'c:/users/x/desktop/backup_saves'
I've tried running cmd as admin but am still getting the same permissions error.我尝试以管理员身份运行 cmd 但仍然遇到相同的权限错误。 Any ideas?
有任何想法吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.