question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
mmagnuskicommented, Jan 19, 2021

I think that given we don’t know what caused the config directory to be unavailable it might be safer to throw a very informative error and ask the user to check what is wrong (and recreate the directory if that is what they want). This seems to be safer and least overkill (on mne side) to me actually.

0reactions
cbrnrcommented, Jan 25, 2021

BTW, using e.g. eegbci.load_data(1, 4) instead of the sample data set works as I expected - it automatically creates the folder even if the folder specified in the config doesn’t exist. I think that’s how it should be for all datasets. So now I can argue that we are already inconsistent, but probably the solution is to add load_data methods to all datasets?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting started with QGIS, but can't find sample data files on ...
The Windows installer has an option to download the QGIS sample dataset. If checked, the data will be downloaded to your My Documents...
Read more >
Path in dataset or folder does not exist - Dataiku Documentation
The specified path in the dataset or folder does not exist. This can happen if a partition is required but does not exist....
Read more >
Newbie question: 'File does not exist' error when loading data
Hi everyone, Newbie question. Am attempting to import a number of datasets that have been placed in the 'data' folder of my working ......
Read more >
Solved: Error: File does not exist (SAS university edition)
I have specified the Libref pathway (I believe). But can not do any proc commands. It says Error: no data set open to...
Read more >
How to download/upload a file produced in the notebook?
Explanation: There's a folder located at /kaggle/working/images_out/Landscapes. This folder is compressed then a working download link is presented. Click the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found