Feona
Feona

Reputation: 77

No such file or directory

import os
from PIL import Image
path='D:/SomeExperiments/KITTRawData/2011_09_26/2011_09_26_drive_0091_sync/image_03/data/0000000100.jpg'
with open(path,'rb') as f:
    pass

error as below

[Errno 2] No such file or directory: 'D:/SomeExperiments/KITTRawData/2011_09_26/2011_09_26_drive_0091_sync/image_03/data/0000000224.jpg'

but I can find this path on my computer: enter image description here

Upvotes: 1

Views: 888

Answers (1)

Possible solution

Hold the shift key and right click on the image file. Select copy as path. Then paste the copied path into your python script. This SHOULD work for sure.

Possible reasons for the error

  1. You are using slashes instead of backslashes - My version of windows and python supports using slashes but I'm not sure if it supports all.

  2. File extension mismatch - Maybe your files are .jpeg and yet you are trying .jpg in your script. Path is not case sensitive in Windows but it's always a good practice to use correct case in the path, for example if your file is aBc.TXT you should use the exact same name not abc.txt.

Upvotes: 1

Related Questions