FileNotFoundError: [Errno 2] No such file or directory: ‘/home/fmriprep/.cache’

I ran the new image and I receive permission denied error.

/home/oad4/scratch60/kpeBIDS /home/oad4/scratch60/output2 \
    participant \
    --skip_bids_validation \
    --fs-license-file /home/oad4/freesurferLicense/license.txt \
    -w /home/oad4/scratch60/work \
    --nthreads 8 \
    --ignore slicetiming \
    --participant_label 1223
/usr/local/miniconda/lib/python3.7/importlib/_bootstrap.py:219: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
  return f(*args, **kwds)
/usr/local/miniconda/lib/python3.7/importlib/_bootstrap.py:219: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
  return f(*args, **kwds)
/usr/local/miniconda/lib/python3.7/importlib/_bootstrap.py:219: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
  return f(*args, **kwds)
/usr/local/miniconda/lib/python3.7/importlib/_bootstrap.py:219: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
  return f(*args, **kwds)
/usr/local/miniconda/lib/python3.7/site-packages/nilearn/datasets/neurovault.py:16: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Container
/usr/local/miniconda/lib/python3.7/site-packages/templateflow/conf/__init__.py:22: ResourceWarning: TemplateFlow: repository not found at /home/fmriprep/.cache/templateflow. Populating a TemplateFlow stub.
If the path reported above is not the desired location for Templateflow, please set the TEMPLATEFLOW_HOME environment variable.

  warn(_msg, ResourceWarning)
/usr/local/miniconda/lib/python3.7/site-packages/datalad/utils.py:75: DeprecationWarning: dist() and linux_distribution() functions are deprecated in Python 3.5
  = platform.linux_distribution()[:2]
/usr/local/miniconda/lib/python3.7/site-packages/datalad/utils.py:903: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  is_decorating = not kwargs and len(args) == 1 and isinstance(args[0], collections.Callable)
/usr/local/miniconda/lib/python3.7/site-packages/datalad/support/param.py:30: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
  _KNOWN_ARGS = getargspec(argparse.Action.__init__)[0] + ['action']
/usr/local/miniconda/lib/python3.7/site-packages/datalad/interface/base.py:321: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
  args, varargs, varkw, defaults = getargspec(func)
Process Process-2:
Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.7/pathlib.py", line 1241, in mkdir
    self._accessor.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/fmriprep/.cache'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/usr/local/miniconda/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/run.py", line 564, in build_workflow
    from ..workflows.base import init_fmriprep_wf
  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/workflows/base.py", line 24, in <module>
    from niworkflows.interfaces.bids import (
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/interfaces/__init__.py", line 9, in <module>
    from .registration import (FLIRTRPT as FLIRT,
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/interfaces/registration.py", line 25, in <module>
    from .mni import (
  File "/usr/local/miniconda/lib/python3.7/site-packages/niworkflows/interfaces/mni.py", line 20, in <module>
    from templateflow.api import get as get_template
  File "/usr/local/miniconda/lib/python3.7/site-packages/templateflow/api.py", line 6, in <module>
    from .conf import TF_LAYOUT, TF_S3_ROOT
  File "/usr/local/miniconda/lib/python3.7/site-packages/templateflow/conf/__init__.py", line 32, in <module>
    TF_HOME.parent.mkdir(exist_ok=True, parents=True)
  File "/usr/local/miniconda/lib/python3.7/pathlib.py", line 1245, in mkdir
    self.parent.mkdir(parents=True, exist_ok=True)
  File "/usr/local/miniconda/lib/python3.7/pathlib.py", line 1241, in mkdir
    self._accessor.mkdir(self, mode)
PermissionError: [Errno 13] Permission denied: '/home/fmriprep'

I’m not sure if its the same issue exactly.

Sorry for that - working on a fix.

1 Like

Could you try the filo/fmriprep:templateflowhomefix image (just landed in docker hub)?

As I’m a docker/singularity newbie - should I just rebuild singularity image or check it manually?

It depends on your system - how did you build/obtained your previous image?

Singularity build…

Try:

SINGULARITY_DISABLE_CACHE=True singularity build /tmp/test_fmriprep_image.simg docker://filo/fmriprep:templateflowhomefix

1 Like

It works.
Thank you!

To get rid of this error you can try using os.listdir() function to check that at least python sees the file exists or not.

When you open a file with the file name , you are telling the open() function that your file is in the current working directory. This is called a relative path. 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 path is interpreted relatively to the current working directory. The current working directory usually is the directory in which you started the program. A good start would be validating the input. In other words, you can make sure that the user has indeed typed a correct path for a real existing file, like this:

while not os.path.isfile(fileName):
    fileName = input("No such file! Please enter the name of the file you'd like to use.")

Another way to tell the python file open() function where your file is located is by using an absolute path, e.g.:

f = open("/Users/foo/filename")