ArmindoFlores
ArmindoFlores

Reputation: 493

Having trouble installing Dropbox API for Python 2.6

I have python 2.6 on Windows. I just installed Dropbox API and when I do:

import dropbox

It gives an error:

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()} 

What can i do?


Reproducible also on 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

Upvotes: 1

Views: 490

Answers (2)

sreenivas
sreenivas

Reputation: 2247

I was desperate to get it working on 2.6 as I can't upgrade to latest versions of python. Finally got it working.

All you need to do is change the dictionary comprehension

From:

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

To:

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

And rest of the module worked as usual so far.

I don't have the rep to add a comment so adding as an answer :)

Upvotes: 2

s-m-e
s-m-e

Reputation: 3711

This is definitely related to Python 2.6. The install-script of Dropbox's Python SDK is already throwing syntax errors when you run it with Python 2.6. Strangely, it keeps running and finishes regardless. Dropbox is not very specific about the required minimal version of Python, but the install-script suggests 2.6. Nevertheless, importing the Dropbox module will fail both on Windows and Linux due to a syntax error.

I just installed Python 2.7.9 in parallel to my original Python 2.6.5 environment. With 2.7, the Dropbox SDK installs and loads without any syntax error at at.

Upvotes: 0

Related Questions