Python Forum
FileNotFoundError: No such file or no access - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: FileNotFoundError: No such file or no access (/thread-21062.html)



FileNotFoundError: No such file or no access - agatte - Sep-12-2019

Hello,

I am begging in python. I compile the code of and I got the error like this:

Quote: File "C:\Users\krasona\PycharmProjects\GlioblastomaSegmentation\venv\lib\site-packages\nibabel\loadsave.py", line 42, in load
raise FileNotFoundError("No such file or no access: '%s'" % filename)
FileNotFoundError: No such file or no access: 'C:\Users\krasona\PycharmProjects\GlioblastomaSegmentation\output\FLAIR_N4Bias.nii.gz'

The code looks like this :
  try:
        stat_result = os.stat(filename)
    except OSError:
        raise FileNotFoundError("No such file or no access: '%s'" % filename)
    if stat_result.st_size <= 0:
        raise ImageFileError("Empty file: '%s'" % filename)
    sniff = None
    for image_klass in all_image_classes:
        is_valid, sniff = image_klass.path_maybe_image(filename, sniff)
        if is_valid:
            img = image_klass.from_filename(filename, **kwargs)
            return img

    raise ImageFileError('Cannot work outfile type of "%s"' %
                         filename)


Could you help me to fix this issue ?

I would be appreciate for any help please.


RE: FileNotFoundError: No such file or no access - luoheng - Sep-12-2019

The error is quite clear.
The file C:\Users\krasona\PycharmProjects\GlioblastomaSegmentation\output\FLAIR_N4Bias.nii.gz doesn't exist, or you don't have access to it.
So check if you have the file, and if you have access.


RE: FileNotFoundError: No such file or no access - agatte - Sep-12-2019

It didn't create this file.
Before It creates another files but this one was not created.