Skip to content

Sample data set cannot be downloaded if data folder does not exist #8764

@cbrnr

Description

@cbrnr

The default location for MNE sample data is ~/mne_data. Apparently, if this folder does not exist the data set cannot be downloaded:

# make sure the folder "~/mne_data" does not exist!
import mne
from mne.datasets import sample


data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'

raw = mne.io.read_raw_fif(raw_fname)

I get the following error:

Downloading archive MNE-sample-data-processed.tar.gz to /Users/clemens/mne_data
Downloading https://files.osf.io/v1/resources/rxvq7/providers/osfstorage/59c0e26f9ad5a1025c4ab159?version=5&action=download&direct (1.54 GB)
  0%|          | Downloading : 0.00/1.54G [00:00<?,        ?B/s]Error while fetching file https://osf.io/86qa2/download?version=5. Dataset fetching aborted.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3418, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-9a4a5c6c7639>", line 1, in <module>
    runfile('/Users/clemens/Library/Application Support/JetBrains/PyCharm2020.3/scratches/scratch.py', wdir='/Users/clemens/Library/Application Support/JetBrains/PyCharm2020.3/scratches')
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/clemens/Library/Application Support/JetBrains/PyCharm2020.3/scratches/scratch.py", line 5, in <module>
    data_path = sample.data_path()
  File "<decorator-gen-461>", line 24, in data_path
  File "/Users/clemens/Repositories/mne-python/mne/datasets/sample/sample.py", line 19, in data_path
    return _data_path(path=path, force_update=force_update,
  File "/Users/clemens/Repositories/mne-python/mne/datasets/utils.py", line 418, in _data_path
    remove_archive, full = _download(path, u, an, h)
  File "/Users/clemens/Repositories/mne-python/mne/datasets/utils.py", line 475, in _download
    _fetch_file(url, full_name, print_destination=False,
  File "<decorator-gen-3>", line 24, in _fetch_file
  File "/Users/clemens/Repositories/mne-python/mne/utils/fetching.py", line 117, in _fetch_file
    _get_http(url, temp_file_name, initial_size, timeout, verbose_bool)
  File "/Users/clemens/Repositories/mne-python/mne/utils/fetching.py", line 55, in _get_http
    with open(temp_file_name, mode) as local_file:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/clemens/mne_data/MNE-sample-data-processed.tar.gz.part'

Everything works as expected if the folder ~/mne_data exists (even if it is just an empty folder). We should automatically create this folder if not present to prevent this error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions