astropy.utils.data.download_file(remote_url, cache=False, show_progress=True, timeout=None, sources=None, pkgname='astropy', http_headers=None)[source]

It returns the filename of a file containing the URL’s contents. If cache=True and the file is present in the cache, just returns the filename; if the file had to be downloaded, add it to the cache.
The cache is effectively a dictionary mapping URLs to files; by default the file contains the contents of the URL that is its key, but in practice these can be obtained from a mirror (using sources) or imported from the local filesystem (using import_file_to_cache or import_download_cache). Regardless, each file is regarded as representing the contents of a particular URL, and this URL should be used to look them up or otherwise manipulate them.
Parameters: remote_url : str The URL of the file to download cache : bool or “update”, optional Whether to cache the contents of remote URLs. If “update”, always download the remote URL in case there is a new version and store the result in the cache. show_progress : bool, optional Whether to display a progress bar during the download (default is True). Regardless of this setting, the progress bar is only displayed when outputting to a terminal. timeout : float, optional The timeout, in seconds. Otherwise, use astropy.utils.data.Conf.remote_timeout. sources : list of str, optional If provided, a list of URLs to try to obtain the file from. The result will be stored under the original URL. The original URL will not be tried unless it is in this list; this is to prevent long waits for a primary server that is known to be inaccessible at the moment. If an empty list is passed, then download_file will not attempt to connect to the Internet. pkgname : str, optional The package name to use to locate the download cache. i.e. for pkgname='astropy' the default cache location is ~/.astropy/cache. http_headers : dict or None HTTP request headers to pass into urlopen if needed. (These headers are ignored if the protocol for the name_or_obj/sources entry is not a remote HTTP URL.) In the default case (None), the headers are User-Agent: some_value and Accept: */*, where some_value is set by astropy.utils.data.conf.default_http_user_agent. local_path : str Returns the local path that the file was download to. urllib.error.URLError Whenever there’s a problem getting the remote file.