gdown: Google Drive Public File/Folder Downloader

5.2.1 · active · verified Thu Apr 09

gdown is a Python package (current version 5.2.1) designed to download public files and folders from Google Drive, providing functionality that standard tools like curl or wget often lack for Google Drive links. It handles large files by skipping security notices and supports recursive downloads for folders (up to 50 files per folder). The library has an active development cycle with regular updates addressing features, enhancements, and bug fixes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to download a publicly accessible file from Google Drive using its URL. The `gdown.download()` function handles the process, including bypassing Google Drive's security notices for large files. The example also includes cleanup for repeatability.

import gdown
import os

# A public Google Drive file URL (replace with your desired file if needed)
# This specific file is a public example from the gdown GitHub repo
url = "https://drive.google.com/uc?id=1l_5RK28JRL19wpT22B-DY9We3TVXnnQQ"
output_filename = "fcn8s_from_caffe.npz"

try:
    gdown.download(url, output_filename, quiet=False)
    print(f"Successfully downloaded {output_filename}")
except Exception as e:
    print(f"Error downloading file: {e}")
finally:
    # Clean up the downloaded file for a repeatable quickstart
    if os.path.exists(output_filename):
        os.remove(output_filename)
        print(f"Cleaned up {output_filename}")

view raw JSON →