cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

The first command dropbox.Dropbox() in the online tutorial encounters 'Cannot find reference'

The first command dropbox.Dropbox() in the online tutorial encounters 'Cannot find reference'

hrh747
Helpful | Level 5
Go to solution

Hi,

I am using Python and I started to learn about the Dropbox APIs by following the online tutorial at Python - Developers - Dropbox

 

I have generated my token through the App Consol, however, the following line of code encounters an error:

import dropbox

MY_TOKEN= 'XYZ'
dbx = dropbox.Dropbox(MY_TOKEN)

The error: **Cannot find reference 'Dropbox' in 'dropbox.py** ?

Any insights will be great.

1 Accepted Solution

Accepted Solutions

Здравко
Legendary | Level 20
Go to solution

@hrh747 wrote:
... It is part of the dropbox library that gets downloaded when a user does **pip install dropbox**.

...


Ok, I see. It's normal to be so, but I have my doubts what actually gets up. Let's make it sure. 😉

Add a line in your code, so it gonna look like:

import dropbox

print("dropbox imported from:", dropbox.__file__)

MY_TOKEN= 'XYZ'
dbx = dropbox.Dropbox(MY_TOKEN)

The only difference is underlined line. Once add the line in your code, run it. It will break again, but before the error, the same you got before, should be a line like "dropbox imported from: /path/to/dropbox.py". Does actual path match your expectations (place where pip has installed dropbox) or not? 🧐 Is there single such line in the result or there is another copy too? 🤔

Can you post the result?

View solution in original post

4 Replies 4

Здравко
Legendary | Level 20
Go to solution

@hrh747 wrote:

...

...
The error: **Cannot find reference 'Dropbox' in 'dropbox.py** ?

Any insights will be great.


Hi @hrh747,

Is there any chance the file, mentioned within the error message, to refers to code you are writing? 🤔 i.e. referred byself (directly or indirectly)! 🧐🙂

Hope this helps.

hrh747
Helpful | Level 5
Go to solution

Hi,

The file dropbox.py is not mine. It is part of the dropbox library that gets downloaded when a user does **pip install dropbox**.

My code was only the two lines I posted previously.

Здравко
Legendary | Level 20
Go to solution

@hrh747 wrote:
... It is part of the dropbox library that gets downloaded when a user does **pip install dropbox**.

...


Ok, I see. It's normal to be so, but I have my doubts what actually gets up. Let's make it sure. 😉

Add a line in your code, so it gonna look like:

import dropbox

print("dropbox imported from:", dropbox.__file__)

MY_TOKEN= 'XYZ'
dbx = dropbox.Dropbox(MY_TOKEN)

The only difference is underlined line. Once add the line in your code, run it. It will break again, but before the error, the same you got before, should be a line like "dropbox imported from: /path/to/dropbox.py". Does actual path match your expectations (place where pip has installed dropbox) or not? 🧐 Is there single such line in the result or there is another copy too? 🤔

Can you post the result?

hrh747
Helpful | Level 5
Go to solution

Whoever you are, you are a genius 🙂 I thank you immensely and yes you solved the problem by suggesting to add that print statement. Apparently, when I started learning Python (a few months ago), I downloaded a sample file from Dropbox and named it dropbox.py and the import statement was picking up that file instead of the one from the library.

 

Thanks once again

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    hrh747 Helpful | Level 5
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?