cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn about updates that we've made to the Search experience on the Android and iOS apps?Well, you can learn from Luke on the Mobile App team right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
1
Ask
2
Comments

python SDK error

python SDK error

scps950707
Explorer | Level 4

similar problem here

 

My code

#!/usr/bin/env python
import dropbox
print(dropbox.__version__)
dbx = dropbox.Dropbox("my token here")
dbx.users_get_current_account()

output

$ ./dbox.py 
7.3.1
Traceback (most recent call last):
  File "./dbox.py", line 5, in <module>
    dbx.users_get_current_account()
  File "/home/scps950707/.local/lib/python2.7/site-packages/dropbox/base.py", line 3277, in users_get_current_account
    None,
  File "/home/scps950707/.local/lib/python2.7/site-packages/dropbox/dropbox.py", line 239, in request
    timeout=timeout)
  File "/home/scps950707/.local/lib/python2.7/site-packages/dropbox/dropbox.py", line 330, in request_json_string_with_retry
    timeout=timeout)
  File "/home/scps950707/.local/lib/python2.7/site-packages/dropbox/dropbox.py", line 414, in request_json_string
    timeout=timeout,
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/sessions.py", line 549, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/sessions.py", line 502, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/sessions.py", line 612, in send
    r = adapter.send(request, **kwargs)
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 587, in urlopen
    timeout_obj = self._get_timeout(timeout)
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 302, in _get_timeout
    return Timeout.from_float(timeout)
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/packages/urllib3/util/timeout.py", line 154, in from_float
    return Timeout(read=timeout, connect=timeout)
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/packages/urllib3/util/timeout.py", line 94, in __init__
    self._connect = self._validate_timeout(connect, 'connect')
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/packages/urllib3/util/timeout.py", line 127, in _validate_timeout
    "int, float or None." % (name, value))
ValueError: Timeout value connect was Timeout(connect=30, read=30, total=None), but it must be an int, float or None.

 

dependency packages of dropbox:

six==1.10.0
typing==3.6.1
urllib3==1.21.1
requests==2.18.1
1 Accepted Solution

Accepted Solutions

Re: python SDK error

Greg-DB
Dropboxer

Thanks for trying that.

 

I did find this issue on the requests GitHub that indicates this should be fixed in 2.18.1 though:

 

https://github.com/requests/requests/issues/4160

 

Can you try adding the print statement in dropbox.py directly (i.e., our library, not your dbox.py) to see if it's somehow picking up a different version?

 

If that's what's happening you should also be able to see where it's coming from by printing requests.__file__ .

View solution in original post

9 Replies 9

Re: python SDK error

Greg-DB
Dropboxer

I can reproduce this with requests==2.18.0, but not requests==2.18.1.

 

Can you double check that 2.18.1 is actually getting used, and not 2.18.0? E.g., try doing this right before the API call, like you're doing with the Dropbox library:

 

import requests
print(requests.__version__)

Re: python SDK error

scps950707
Explorer | Level 4

Problem still meet

#!/usr/bin/env python
import dropbox
import requests
import six
import sys
print('python:'+sys.version)
print('dropbox:'+dropbox.__version__)
print('requests:'+requests.__version__)
print('six:'+six.__version__)
dbx = dropbox.Dropbox("my token")
dbx.users_get_current_account()

output:

$ ./dbox.py 
python:2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609]
dropbox:7.3.1
requests:2.18.1
six:1.10.0
Traceback (most recent call last):
  File "./dbox.py", line 11, in <module>
    dbx.users_get_current_account()
  File "/home/scps950707/.local/lib/python2.7/site-packages/dropbox/base.py", line 3277, in users_get_current_account
    None,
  File "/home/scps950707/.local/lib/python2.7/site-packages/dropbox/dropbox.py", line 239, in request
    timeout=timeout)
  File "/home/scps950707/.local/lib/python2.7/site-packages/dropbox/dropbox.py", line 330, in request_json_string_with_retry
    timeout=timeout)
  File "/home/scps950707/.local/lib/python2.7/site-packages/dropbox/dropbox.py", line 414, in request_json_string
    timeout=timeout,
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/sessions.py", line 549, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/sessions.py", line 502, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/sessions.py", line 612, in send
    r = adapter.send(request, **kwargs)
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 587, in urlopen
    timeout_obj = self._get_timeout(timeout)
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 302, in _get_timeout
    return Timeout.from_float(timeout)
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/packages/urllib3/util/timeout.py", line 154, in from_float
    return Timeout(read=timeout, connect=timeout)
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/packages/urllib3/util/timeout.py", line 94, in __init__
    self._connect = self._validate_timeout(connect, 'connect')
  File "/home/scps950707/.local/lib/python2.7/site-packages/requests/packages/urllib3/util/timeout.py", line 127, in _validate_timeout
    "int, float or None." % (name, value))
ValueError: Timeout value connect was Timeout(connect=30, read=30, total=None), but it must be an int, float or None.

 

My platform is ubuntu 16.04 LTS 

Re: python SDK error

Greg-DB
Dropboxer

Thanks for trying that.

 

I did find this issue on the requests GitHub that indicates this should be fixed in 2.18.1 though:

 

https://github.com/requests/requests/issues/4160

 

Can you try adding the print statement in dropbox.py directly (i.e., our library, not your dbox.py) to see if it's somehow picking up a different version?

 

If that's what's happening you should also be able to see where it's coming from by printing requests.__file__ .

Re: python SDK error

scps950707
Explorer | Level 4

I get same version output of request by putting print __version__ statement directly into dropbox.py, quite strange...

 

But I resolve this issue by fully remove the dropbox,requests package inside the ~/.local/lib/python2.7/site-packages and reinstall with pip

and it works, thanks for support!

 

Re: python SDK error

kaamoo_api
Explorer | Level 3

Hi

 

I'm trying to create an app on my phone that uses dropbox API like folder. Now i'm using kivy librarie with python, and buildozer to create and pushing the app on my phone. In my buildozer requirements i have:

 

six==1.10.0,
typing==3.6.1,
urllib3==1.21.1,
requests==2.18.1

 

Part of my code where i'm using dropbox is: 

 

def connect_to_database(path):

TOKEN = "my_token"

yourpath = '/INVENTARIO.xlsx'

try:
print("Dentro de connect")
dbx = dropbox.Dropbox(TOKEN)
print(str(dbx.users_get_current_account()))

for entry in dbx.files_list_folder('').entries:
print(entry.name)
metadata_name = dbx.files_get_metadata('/INVENTARIO.xlsx')
print(metadata_name)

except Exception as e:
print(e)

 

Everytime that i interact with dropbox in my logcat when app is running on my phone i got:

 

ValueError: Timeout value connect was Timeout(connect=None, read=None, total=None), but it must be an int, float or None.

10-26 08:04:03.906 8658 8696 I python : File "/home/isabel-labenac/Escritorio/applabenac/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/applabenac/urllib3/util/timeout.py", line 137, in _validate_timeout

 

I dont know what is the problem, because, when i try the app on my computer everything goes fine, but when i want to create the app, in the moment when runs on phone this happens.

 

Thans in advance

 

Re: python SDK error

Greg-DB
Dropboxer

@kaamoo_api This should have been fixed by v2.18.1 of requests. It sounds like perhaps your app on your phone somehow isn't actually using that version. Can you try adding some logging to see what version is actually being used there?

Re: python SDK error

kaamoo_api
Explorer | Level 3

@Greg-DB , You were right, I had a problem declaring the version and even when I had it installed, due to a bug with buildocer, the program could not update. After performing a buildozer cleanup and re-declaring requests with version 2.18.1, communication with Dropbox already works correctly.
Thanks for your answer!
Best regards

 

@kaamoo_api

Re: python SDK error

kaamoo_api
Explorer | Level 3

Hi again!

 

When i solved the problem woth requests 2.18.1, the next time that i use the app shows me this error:

 

11-05 12:15:52.071 5473 5509 I python : HTTPSConnectionPool(host='api.dropboxapi.com', port=443): Max retries exceeded with url: /2/users/get_current_account (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xe8b980a0>: Failed to establish a new connection: [Errno 7] No address associated with hostname'))

 

I dont understand what is the problem now.

 

Thanks in advance

 

Kaamoo_api

Re: python SDK error

Greg-DB
Dropboxer

@kaamoo_api Based on the error "No address associated with hostname" it sounds like your system wasn't able to look up the Dropbox API hostname, which is 'api.dropboxapi.com'. You have the right hostname, and 'api.dropboxapi.com' is currently resolving properly, so it sounds like there's an issue with your DNS configuration. You'll need to debug that to see why your system isn't able to complete that lookup successfully. For instance, check what DNS server you're using and check that it's working properly.

Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    kaamoo_api Explorer | Level 3
What do Dropbox user levels mean?
Need more support?