Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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
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.
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.
Hi there!
If you need more help you can view your support options (expected response time for a 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!