FileNotFoundError: [Errno 2] No such file or directory: '/content/data/images/ -Tz7W_t25Xg.JPEG'

I Tried to create a Imagedatabunch from df but when I try to train I got this error:
FileNotFoundError: [Errno 2] No such file or directory: ‘/content/data/images/ -Tz7W_t25Xg.JPEG’
I saw that the path has a space on it, from …images/ to image name, but I couldn’t realize why, as the row from df was ok. below is the error message the data frame as input.
2 3
Here is the full error:

FileNotFoundError Traceback (most recent call last)
in ()
----> 1 data.show_batch(rows=3, figsize=(7,8))

12 frames
/usr/local/lib/python3.6/dist-packages/fastai/basic_data.py in show_batch(self, rows, ds_type, reverse, **kwargs)
184 def show_batch(self, rows:int=5, ds_type:DatasetType=DatasetType.Train, reverse:bool=False, **kwargs)->None:
185 “Show a batch of data in ds_type on a few rows.”
–> 186 x,y = self.one_batch(ds_type, True, True)
187 if reverse: x,y = x.flip(0),y.flip(0)
188 n_items = rows **2 if self.train_ds.x._square_show else rows

/usr/local/lib/python3.6/dist-packages/fastai/basic_data.py in one_batch(self, ds_type, detach, denorm, cpu)
167 w = dl.num_workers
168 dl.num_workers = 0
–> 169 try: x,y = next(iter(dl))
170 finally: dl.num_workers = w
171 if detach: x,y = to_detach(x,cpu=cpu),to_detach(y,cpu=cpu)

/usr/local/lib/python3.6/dist-packages/fastai/basic_data.py in iter(self)
73 def iter(self):
74 “Process and returns items from DataLoader.”
—> 75 for b in self.dl: yield self.proc_batch(b)
76
77 @classmethod

/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in next(self)
343
344 def next(self):
–> 345 data = self._next_data()
346 self._num_yielded += 1
347 if self._dataset_kind == _DatasetKind.Iterable and \

/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in _next_data(self)
383 def _next_data(self):
384 index = self._next_index() # may raise StopIteration
–> 385 data = self._dataset_fetcher.fetch(index) # may raise StopIteration
386 if self._pin_memory:
387 data = _utils.pin_memory.pin_memory(data)

/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py in fetch(self, possibly_batched_index)
42 def fetch(self, possibly_batched_index):
43 if self.auto_collation:
—> 44 data = [self.dataset[idx] for idx in possibly_batched_index]
45 else:
46 data = self.dataset[possibly_batched_index]

/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py in (.0)
42 def fetch(self, possibly_batched_index):
43 if self.auto_collation:
—> 44 data = [self.dataset[idx] for idx in possibly_batched_index]
45 else:
46 data = self.dataset[possibly_batched_index]

/usr/local/lib/python3.6/dist-packages/fastai/data_block.py in getitem(self, idxs)
653 idxs = try_int(idxs)
654 if isinstance(idxs, Integral):
–> 655 if self.item is None: x,y = self.x[idxs],self.y[idxs]
656 else: x,y = self.item ,0
657 if self.tfms or self.tfmargs:

/usr/local/lib/python3.6/dist-packages/fastai/data_block.py in getitem(self, idxs)
118 “returns a single item based if idxs is an integer or a new ItemList object if idxs is a range.”
119 idxs = try_int(idxs)
–> 120 if isinstance(idxs, Integral): return self.get(idxs)
121 else: return self.new(self.items[idxs], inner_df=index_row(self.inner_df, idxs))
122

/usr/local/lib/python3.6/dist-packages/fastai/vision/data.py in get(self, i)
269 def get(self, i):
270 fn = super().get(i)
–> 271 res = self.open(fn)
272 self.sizes[i] = res.size
273 return res

/usr/local/lib/python3.6/dist-packages/fastai/vision/data.py in open(self, fn)
265 def open(self, fn):
266 “Open image in fn, subclass and overwrite for custom behavior.”
–> 267 return open_image(fn, convert_mode=self.convert_mode, after_open=self.after_open)
268
269 def get(self, i):

/usr/local/lib/python3.6/dist-packages/fastai/vision/image.py in open_image(fn, div, convert_mode, cls, after_open)
396 with warnings.catch_warnings():
397 warnings.simplefilter(“ignore”, UserWarning) # EXIF warning from TiffPlugin
–> 398 x = PIL.Image.open(fn).convert(convert_mode)
399 if after_open: x = after_open(x)
400 x = pil2tensor(x,np.float32)

/usr/local/lib/python3.6/dist-packages/PIL/Image.py in open(fp, mode)
2807
2808 if filename:
-> 2809 fp = builtins.open(filename, “rb”)
2810 exclusive_fp = True
2811

FileNotFoundError: [Errno 2] No such file or directory: ‘/content/data/images/ -fyyIZjcrq0.JPEG’

What dataset are you working on? Is it a custom dataset?
From the first looks, it seems that there is a naming error , and hence a mismatch in the names of input and corresponding output files. Most probably because of that extra space.
Make sure that the input and output file names are exactly the same, and you should be good to go.

yes, it is a custom dataset.

I realized that some filenames starting with “-” “_” was driving to that error, for fast solving I removed those corresponding rows from my df and everything worked, next I will adjust the naming.
thanks for the help.