gpt4 book ai didi

python - 为 Python 2.6 安装 Dropbox API 时遇到问题

转载 作者:可可西里 更新时间:2023-11-01 11:52:40 27 4
gpt4 key购买 nike

我在 Windows 上安装了 python 2.6。我刚刚安装了 Dropbox API,当我安装时:

import dropbox

报错:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build\bdist.win32\egg\dropbox\__init__.py", line 3, in <module>
# $Id$
File "build\bdist.win32\egg\dropbox\client.py", line 22, in <module>
File "C:\Python26\lib\site-packages\dropbox-2.2.0-py2.6.egg\dropbox\rest.py", line 415
utf8_params = {encode(k): encode(v) for k, v in params.iteritems()}

我能做什么?


也可在 Linux 上重现:

#> python
Python 2.6.5 (r265:79063, May 6 2011, 16:17:46)
[GCC 4.5.0 20100604 [gcc-4_5-branch revision 160292]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dropbox
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/site-packages/dropbox-2.2.0-py2.6.egg/dropbox/__init__.py", line 3, in <module>
from . import client, rest, session
File "/usr/local/lib/python2.6/site-packages/dropbox-2.2.0-py2.6.egg/dropbox/client.py", line 22, in <module>
from .rest import ErrorResponse, RESTClient, params_to_urlencoded
File "/usr/local/lib/python2.6/site-packages/dropbox-2.2.0-py2.6.egg/dropbox/rest.py", line 415
utf8_params = {encode(k): encode(v) for k, v in params.iteritems()}
^
SyntaxError: invalid syntax

最佳答案

我迫切希望它能在 2.6 上运行,因为我无法升级到最新版本的 python。终于成功了。

你需要做的就是改变字典理解

来自:

utf8_params = {encode(k): encode(v) for k, v in params.iteritems()}

收件人:

for k, v in params.iteritems():
utf8_params[encode(k)] = encode(v)

到目前为止,模块的其余部分照常工作。

我没有代表来添加评论,所以添加为答案:)

关于python - 为 Python 2.6 安装 Dropbox API 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26574521/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com