python - Pydrive 后端不适用于口是心非——python

标签 python duplicity

我正在尝试对 PyDrive 使用双重/口是心非。但是,我不断收到一条非常神秘的错误消息,告诉我引用 PyDrive 安装联机帮助页。没有提供解决方案。

这是我正在运行的重复命令的输出,包括错误。

$ duply mac-mini.gdrive status
Start duply v1.11.1, time is 2016-02-20 19:28:59.
Using profile '/etc/duply/mac-mini.gdrive'.
Using installed duplicity version 0.7.06, python 2.7.10, gpg 1.4.19 (Home: ~/.gnupg), awk 'awk version 20070501', grep 'grep (BSD grep) 2.5.1-FreeBSD', bash '4.3.42(1)-release (x86_64-apple-darwin14.5.0)'.
Checking TEMP_DIR '/tmp' is a folder and writable (OK)
Test - En/Decryption skipped. (GPG disabled)

--- Start running command STATUS at 19:29:00.000 ---
BackendException: PyDrive backend requires PyDrive installationPlease read the manpage to fix.
19:29:00.000 Task 'STATUS' failed with exit code '23'.
--- Finished state FAILED 'code 23' at 19:29:00.000 - Runtime 00:00:00.000 ---

我运行的是 OS X 10.11.3,安装了 brew 和 pip。我使用 pip 安装 pydrive。

$ pip install pyDrive
Requirement already satisfied (use --upgrade to upgrade): pyDrive in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): google-api-python-client>=1.2 in /Library/Python/2.7/site-packages (from pyDrive)
Requirement already satisfied (use --upgrade to upgrade): PyYAML>=3.0 in /Library/Python/2.7/site-packages (from pyDrive)
Requirement already satisfied (use --upgrade to upgrade): six<2,>=1.6.1 in /Library/Python/2.7/site-packages (from google-api-python-client>=1.2->pyDrive)
Requirement already satisfied (use --upgrade to upgrade): oauth2client<3,>=2.0.0 in /Library/Python/2.7/site-packages (from google-api-python-client>=1.2->pyDrive)
Requirement already satisfied (use --upgrade to upgrade): httplib2<1,>=0.8 in /Library/Python/2.7/site-packages (from google-api-python-client>=1.2->pyDrive)
Requirement already satisfied (use --upgrade to upgrade): uritemplate<1,>=0.6 in /Library/Python/2.7/site-packages (from google-api-python-client>=1.2->pyDrive)
Requirement already satisfied (use --upgrade to upgrade): pyasn1>=0.1.7 in /Library/Python/2.7/site-packages (from oauth2client<3,>=2.0.0->google-api-python-client>=1.2->pyDrive)
Requirement already satisfied (use --upgrade to upgrade): pyasn1-modules>=0.0.5 in /Library/Python/2.7/site-packages (from oauth2client<3,>=2.0.0->google-api-python-client>=1.2->pyDrive)
Requirement already satisfied (use --upgrade to upgrade): rsa>=3.1.4 in /Library/Python/2.7/site-packages (from oauth2client<3,>=2.0.0->google-api-python-client>=1.2->pyDrive)
Requirement already satisfied (use --upgrade to upgrade): simplejson>=2.5.0 in /Library/Python/2.7/site-packages (from uritemplate<1,>=0.6->google-api-python-client>=1.2->pyDrive)

作为引用,我正在运行 duplicity 和 duply 的当前版本。

$ duply -V
  duply version 1.11.1
  (http://duply.net)

  Using installed duplicity version 0.7.06, python 2.7.10, gpg 1.4.19 (Home: ~/.gnupg), awk 'awk version 20070501', grep 'grep (BSD grep) 2.5.1-FreeBSD', bash '4.3.42(1)-release (x86_64-apple-darwin14.5.0)'.

最佳答案

2016/04/25 更新:

从口是心非的 0.7.07.1 开始,与 python2-oauth2client 2.00 的不兼容性已得到修复(参见 changelog)。我刚刚在 Linux 机器上对其进行了测试,它运行良好。

原文如下:

首先,检查您的 python2-oauth2client 版本。在编写此版本时,2.00 似乎还不能与口是心非一起工作。我不得不降级回 1.5.2 以使其再次运行。

其次,确保没有由不同 python 版本引起的冲突(OSX 内置与自制程序包与手动安装与 pip 等)。专门使用自制软件可能是个好主意。

第三,确保你的pydrive配置完成。以下是如何使用“普通”Google 用户帐户执行此操作的简要说明:

第一步:创建pydrive后端配置文件

在某处创建一个 pydrive 配置文件(例如 /etc/duply/pydrive.conf~/etc/pydrive.conf),内容如下:

client_config_backend: settings
client_config:
    client_id: <client-id-string>.apps.googleusercontent.com
    client_secret: <client-secret-string>
save_credentials: True
save_credentials_backend: file
save_credentials_file: </path/to/save/authdata.json>
get_refresh_token: True
  • client_idclient_secret 可以从 Google Developers Console 的 API 管理器中获取在Google Drive API之后已启用。

  • save_credentials_file 设置为 pydrive 在成功连接后可以缓存身份验证数据的任意位置(例如 /etc/duply/pydrive.json~/etc/pydrive.json).

第 2 步:告诉口是心非在哪里可以找到它

这是通过设置 GOOGLE_DRIVE_SETTINGS shell 变量来完成的:

$ export GOOGLE_DRIVE_SETTINGS=/etc/duply/pydrive.conf

您可能想将它添加到您的 ~/.bashrc 以便所有 shell session 都自动设置它。

第三步:首次认证

引自口是心非的联机帮助页:

During the first run, you will be prompted to visit an URL in your browser to grant access to your drive. Once granted, you will receive a verification code to paste back into Duplicity. The credentials are then cached in the file references above for future use.

... 大功告成。

疑难解答

如果这仍然不起作用,请检查文件权限:运行口是心非的用户是否对上面指定的配置文件有足够的权限?

关于python - Pydrive 后端不适用于口是心非——python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35528278/

相关文章:

python - WebDriverException : Message: 'Can not connect to the ChromeDriver' . utils.is_connectable(self.port) 错误:

python - 按两次删除的ForeignKey对象过滤

ubuntu - 另一个重复实例已在此存档目录中运行

macos - Duplicity 不喜欢 Mavericks 上的最大打开文件设置

备份多个文件夹(包括/不包括)

python - 如何从 model+ModelForm 获取文本区域?

Python - 从脚本到 Web 应用程序?

python - 如何使用selenium调用angular函数(ng-click)

python - 使用口是心非上传到 Swift 伪文件夹

python - 口是心非在 macOS 上不起作用,得到 : env: python2: No such file or directory