FileNotFoundError: [Errno 2] No such file or directory ,even I have the image in that particular folder
Your path is incorrect when you open the single image, it should be:
a = Image.open(path2 + '\\'+ imlist[0])
FileNotFoundError: [Errno 2] No such file or directory for pictures on Python 3.7
If the image file "v" is in the same folder as your python code, your code should load it. The error shows it is missing the file. I would recommend checking for file extensions (maybe file name is "v.jpg").
And if your file is not in the python folder and is in a different folder,
the easiest way is to include the full address to your image file:
image=Image.open("full_path_to_file/"+"v")
The same approach with better practice would be like this:
import os
image=Image.open(os.path.join("full_path_to_file", "v"))
You can also use the relational address to file. "../" will take you to one directory above your current directory. For example, if your file directory structure is:
- directory
- |
- v.jpg
- subdirectory
- |
- your_python_code.py
You can use:
image=Image.open("../v")
FileNotFoundError: [Errno 2] No such file or directory in Opencv face_recognition python
It says that there is no such directory as a.jpg in the "dataset" folder
No, that is not what the error means.
The code is looking for that file in the current directory, not in the dataset folder.
You did call os.listdir(r'/home/pi/Desktop/dataset/')
, but that does not change the current directory.
Use the full pathname to open the file:
img=face_recognition.load_image_file("/home/pi/Desktop/dataset/a.jpg")
Related Topics
Check If Value from One Dataframe Exists in Another Dataframe
Find and Replace Specific Values Within 2D Array
How to Clear Your Printed Text in Python
Regular Expression: Match Everything After a Particular Word
How to Reset Anaconda Root Environment
How to Remove the Decimal Point in a Pandas Dataframe
Pandas Populate New Dataframe Column Based on Matching Columns in Another Dataframe
Checking If a Button Has Been Pressed in Python
Find Specific Words in Text File and Print the Line Using Python
Counting Non Zero Values in Each Column of a Dataframe in Python
Deal With Overflow in Exp Using Numpy
How to Plot Predicted Values VS the True Value
How to Get Slope from Timeseries Data in Pandas
How to Delete Blank Lines from CSV File
How to Plot Date and Time in X Axis Against Y Value (Python)