Python Forum

Full Version: FileNotFoundError: No such file or no access
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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.
It didn't create this file.
Before It creates another files but this one was not created.