face_recognition icon indicating copy to clipboard operation
face_recognition copied to clipboard

File Not Found Error

Open nortjaco opened this issue 6 years ago • 2 comments

  • face_recognition version:
  • Python version:
  • Operating System:

Description

Amazing code btw, I am a beginner and I copied the code for the live webcam into my windows 10 command prompt, I changed the first image and face encoding to put my own in there, but it says it can't be found.

What I Did

This is what i changed

me_image = face_recognition.load_image_file("me.jpg")
me_face_encoding = face_recognition.face_encodings(me_image)[0]

This is what I get

Traceback (most recent call last):
  File "live_face_camera_add_people", line 14, in <module>
    me_image = face_recognition.load_image_file("me.jpg")
  File "C:\Users\jnort\AppData\Local\Programs\Python\Python37-32\lib\site-packages\face_recognition\api.py", line 83, in load_image_file
    im = PIL.Image.open(file)
  File "C:\Users\jnort\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PIL\Image.py", line 2652, in open
    fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'me.jpg'
[ WARN:0] terminating async callback

Please Help!!!

nortjaco avatar Apr 17 '19 02:04 nortjaco

Is "me.jpg" in the same directory the script is running from? If not, either put it there, or try setting an absolute path.

me_image = face_recognition.load_image_file("C:\Users\Jacob\Pictures\me.jpg")

or whatever

janipewter avatar Apr 23 '19 11:04 janipewter

If you haven't yet solved the issue, here are a few things that fixed my error:

  1. Make sure your image and script are in the same directory.
  2. Next, Just include file on its own, without the folder. eg: Instead of "Folder/file.jpg", change it to, "file.jpg"

ghost avatar Apr 26 '21 11:04 ghost