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.

FileNotFoundError: File not found: "data"

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Bug summary

I have searched issue, there is only one similar issue about file not found path. I followed the guide in that issue, update my torchio and torch, but this error still be there.

Code for reproduction

class iosampler(torch.utils.data.Dataset):
    def __init__(self,input_list,label_list):

        self.input_list=input_list
        self.label_list=label_list
        self.probalities={0:0,19:1,20:1,21:1,22:1,23:1,24:1}
        Subject=[]
        for item1,item2 in zip(self.input_list,self.label_list):
            Subject.append(
                tio.Subject(
                    input=tio.ScalarImage(item1),
                    seg=tio.LabelMap(item2))
            )
        sampler=tio.data.LabelSampler(
            patch_size=128,
            label_probabilities=self.probalities,
        )
        self.training_Set=tio.SubjectsDataset(Subject)
        self.Queue=tio.Queue(
            self.training_Set,
            4,
            4,
            sampler,
            num_workers=8,
            shuffle_subjects=True,
            shuffle_patches=True,
        )

.....
TrainDataset=iosampler(Tr_data_list,Tr_label_list)
DataLoader=torch.utils.data.DataLoader(TrainDataset.Queue,shuffle=True,batch_size=8)

Actual outcome

raise FileNotFoundError(f’File not found: “{path}”') The path value is a posixpath value: data

Error messages

Traceback (most recent call last):**  

  File "../main.py", line 119, in main  
    for i,batch in enumerate(DataLoader):  
  File "../torch/utils/data/dataloader.py", line 530, in __next__  
    data = self._next_data()

  File "../torch/utils/data/dataloader.py", line 570, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration  

  File "../torch/utils/data/_utils/fetch.py", line 52, in fetch
    return self.collate_fn(data)  

  File "../torch/utils/data/_utils/collate.py", line 157, in default_collate
    return elem_type({key: default_collate([d[key] for d in batch]) for key in elem})  

  File "../torch/utils/data/_utils/collate.py", line 157, in <dictcomp>
    return elem_type({key: default_collate([d[key] for d in batch]) for key in elem})  

  File "../torch/utils/data/_utils/collate.py", line 157, in default_collate
    return elem_type({key: default_collate([d[key] for d in batch]) for key in elem})  

  File "../torchio/data/image.py", line 750, in __init__
    super().__init__(*args, **kwargs)  

  File "../torchio/data/image.py", line 161, in __init__
    self.path = self._parse_path(path)  

  File "../torchio/data/image.py", line 431, in _parse_path
    return [self._parse_single_path(p) for p in path]  

  File "../torchio/data/image.py", line 431, in <listcomp>
    return [self._parse_single_path(p) for p in path]  

  File "../torchio/data/image.py", line 419, in _parse_single_path
    raise FileNotFoundError(f'File not found: "{path}"')  

FileNotFoundError: File not found: "data"

Expected outcome

normal dataloader

System info

Ubuntu: Ubuntu 20.04.3 LTS
torch              1.12.1+cu113
torchaudio         0.12.1+cu113
torchio            0.18.84
torchvision        0.13.1+cu113

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
fepegarcommented, Nov 19, 2022

This should be solved in v0.18.86. Thank you both for reporting!

1reaction
fepegarcommented, Nov 19, 2022

I was just testing whether the CI would be happy with the changes. Then I thought I give you the chance to contribute. I’ll just make you a co-author of the merge commit, if that’s ok.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Why am I getting a FileNotFoundError? - Stack Overflow
import os fileName = input("Please enter the name of the file you'd like to use.") while not os.path.isfile(fileName): fileName = input("Whoops!
Read more >
Python FileNotFoundError: [Errno 2] No such file or directory ...
The Python FileNotFoundError: [Errno 2] No such file or directory error is often raised by the os library. This error tells you that...
Read more >
FileNotFoundError: [Errno 2] No such file or directory
The Python "FileNotFoundError: [Errno 2] No such file or directory" occurs when we try to open a file that doesn't exist in the...
Read more >
FileNotFoundError: [Errno 2] No such ... - Net-Informations.Com
There are several other reasons why the FileNotFoundError Errno 2 No such file or directory error can occur: ... There may be times...
Read more >
How to fix FileNotFoundError Errno 2 no such file or directory
The error FileNotFoundError Errno 2 no such file or directory occurs when Python cannot find the specified file in the current directory. ·...
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