Forums

Issue with connecting to Dropbox

Hi everyone,

I am Mike and I am new at PythonAnywhere, but I love it and decided upgraded it to a $6/month account!

I have a small issue and maybe somebody can help me. I use PythonAnywhere mainly for webscrapping and it would be very useful if I could upload the result generated by few of my codes to my own dropbox account. To do so, I created an access token from dropbox and using it in the following code (as an exemple):

Import dropbox
access_token  = 'the code generated by the dropbox website'
client = dropbox.client.DropboxClient(access_token)
print 'linked account: ', client.account_info()

I have the following error message:

linked account:                                                                                                                   
Traceback (most recent call last):                                                                                  
File "/home/wizmike/mscrpt2/dropbox_init.py", line 5, in <module>                                                               
print 'linked account: ', client.account_info()                                                                               
 File "/usr/local/lib/python2.7/dist-packages/dropbox/client.py", line 139, in account_info                                      
url, params, headers = self.request("/account/info", method='GET')                                                            
  File "/usr/local/lib/python2.7/dist-packages/dropbox/client.py", line 118, in request                                           
host = self.session.API_CONTENT_HOST if content_server else self.session.API_HOST                                             
AttributeError: 'str' object has no attribute 'API_HOST'

When I run my code on my local computer, it works fine.

I triend to look in the forums for an answer but did not find any.

Any help would be very appreciated.

Thanks,

Mike

Hi Mike, thanks for upgrading!

I wonder if it could be to do with different versions of the dropbox api on your PC and on PythonAnywhere? Can I recommend setting up a virtualenv, both on your PC and on PythonAnywhere, so you can make sure you're using the same version in both places?

If you've never used one before, do a bit of googling to understand virtualenvs, they're really useful. And we're here to help if you get stuck...