You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

hrh747's avatar
hrh747
Helpful | Level 5
4 years ago

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

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.


  • 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?

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    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's avatar
      hrh747
      Helpful | Level 5

      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.

      • Здравко's avatar
        Здравко
        Legendary | Level 20

        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?

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,888 PostsLatest Activity: 2 days ago
326 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!