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: 

FileNotFoundError: [Errno 2] No such file or directory

FileNotFoundError: [Errno 2] No such file or directory

keano16
New member | Level 2

Hi

 

I'm trying to download a dropbox link to a .xlsx file using the following script but am getting the error "FileNotFoundError: [Errno 2] No such file or directory: '/downloadfolder/subfolder' ", that directory does exist i can see it and have also listed files in that directory using files_list_folder. I've searched similar errors on here but can't get it to work, any ideas what I'm doing wrong?

 

import dropbox
dbx = dropbox.Dropbox('TOKEN')
download_path = '/downloadfolder/subfolder'
path = '/folder/file.xlsx
dbx.files_download_to_file(download_path,path)

I've also tried downloading the link via sharing_get_shared_link_file_to_file aswell but get the same error:

download_path = '/downloadfolder/subfolder'
url_file = ('https://www.dropbox.com/scl/fi/sometext/file.xlsx?dl=0&rlkey=sometext')
dbx.sharing_get_shared_link_file_to_file(download_path, url_file)

Thanks in advance

 

2 Replies 2

Greg-DB
Dropbox Staff

The FileNotFoundError "No such file or directory" error here is referring to the location on your local filesystem, not in the remote Dropbox account. That is, the first parameter you supply to files_download_to_file (and sharing_get_shared_link_file_to_file as well) is the "Path on local machine to save file". (For comparison, files_list_folder lists the contents of the remote Dropbox account.) 

 

So, you should update your 'download_path' value to point to an actual location on your local filesystem, or otherwise update your local filesystem to contain that path (e.g., put a "downloadfolder" folder in your filesystem root, etc.). 

 

Also, note that the value you provide there should be the full path, including filename and extension, so you would probably want to make it something like '/downloadfolder/subfolder/file.xlsx', in addition to making sure the folder(s) exist locally.

lovelmark
New member | Level 2

If the user does not pass the full path to the file (on Unix type systems this means a path that starts with a slash), the python file path is interpreted relatively to the current working directory. The current working directory usually is the directory in which you started the program. In order to make this work, the directory containing the python executable must be in the PATH, a so-called environment variable that contains directories that are automatically used for searching executables when you enter a command.

 

In any case, if your Python script file and your data input file are not in the same directory, you always have to specify either a relative path between them or you have to use an absolute path for one of them.

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    lovelmark New member | Level 2
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?