FileNotFoundError: [WinError 2] The system cannot find the file specified: exiftool
FileNotFoundError: [WinError 2] The system cannot find the file specified: exiftool
我正在尝试从 mp4/jpg 文件中提取元数据。我正在使用 exiftool,但如果有更好的东西请说。我想从一个视频开始,将帧提取为 jpg,然后将元数据添加到每个帧,图像的每个元数据应该略有不同,例如时间和焦距。
这是我尝试 https://smarnach.github.io/pyexiftool/ 的开始。我不认为它甚至像 et 一样加载,但我是新手,不知道可能是什么问题?
这是 MWE(几乎就是文档中的内容)- 无论我使用 .jpg 还是 .mp4,它的作用都是一样的
import exiftool
files = ['file.MP4', 'file.MP4']
with exiftool.ExifTool() as et:
metadata = et.get_metadata_batch(files)
for d in metadata:
print("{:20.20} {:20.20}".format(d["SourceFile"],
d["EXIF:DateTimeOriginal"]))
和错误:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-4-2bf611f4ab6b> in <module>
9 files = ['file.MP4', 'file1.MP4']
10
---> 11 with exiftool.ExifTool() as et:
12 metadata = et.get_metadata_batch(files)
13 for d in metadata:
C:\ProgramData\Anaconda3\lib\site-packages\exiftool.py in __enter__(self)
189
190 def __enter__(self):
--> 191 self.start()
192 return self
193
C:\ProgramData\Anaconda3\lib\site-packages\exiftool.py in start(self)
172 "-common_args", "-G", "-n"],
173 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
--> 174 stderr=devnull)
175 self.running = True
176
C:\ProgramData\Anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
727 c2pread, c2pwrite,
728 errread, errwrite,
--> 729 restore_signals, start_new_session)
730 except:
731 # Cleanup if the child failed starting.
C:\ProgramData\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
1015 env,
1016 os.fspath(cwd) if cwd is not None else None,
-> 1017 startupinfo)
1018 finally:
1019 # Child is launched. Close the parent's copy of those pipe
FileNotFoundError: [WinError 2] The system cannot find the file specified
您使用 pyexiftool
的方式要求 exiftool
在 $PATH
环境变量中列出的目录中可用。
打开 cmd
window,输入命令 exiftool
并点击 enter
。如果这也是 returns 一个 "file not found" 错误,那么
exiftool
未安装或
- 安装
exiftool
的目录不在路径中
在情况 (2) 中,您可以在构造函数中提供 exiftool
可执行文件的完整路径。例如:
exiftool.ExifTool(r'C:\program files\exiftool\exiftool.exe')
我正在尝试从 mp4/jpg 文件中提取元数据。我正在使用 exiftool,但如果有更好的东西请说。我想从一个视频开始,将帧提取为 jpg,然后将元数据添加到每个帧,图像的每个元数据应该略有不同,例如时间和焦距。
这是我尝试 https://smarnach.github.io/pyexiftool/ 的开始。我不认为它甚至像 et 一样加载,但我是新手,不知道可能是什么问题?
这是 MWE(几乎就是文档中的内容)- 无论我使用 .jpg 还是 .mp4,它的作用都是一样的
import exiftool
files = ['file.MP4', 'file.MP4']
with exiftool.ExifTool() as et:
metadata = et.get_metadata_batch(files)
for d in metadata:
print("{:20.20} {:20.20}".format(d["SourceFile"],
d["EXIF:DateTimeOriginal"]))
和错误:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-4-2bf611f4ab6b> in <module>
9 files = ['file.MP4', 'file1.MP4']
10
---> 11 with exiftool.ExifTool() as et:
12 metadata = et.get_metadata_batch(files)
13 for d in metadata:
C:\ProgramData\Anaconda3\lib\site-packages\exiftool.py in __enter__(self)
189
190 def __enter__(self):
--> 191 self.start()
192 return self
193
C:\ProgramData\Anaconda3\lib\site-packages\exiftool.py in start(self)
172 "-common_args", "-G", "-n"],
173 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
--> 174 stderr=devnull)
175 self.running = True
176
C:\ProgramData\Anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
727 c2pread, c2pwrite,
728 errread, errwrite,
--> 729 restore_signals, start_new_session)
730 except:
731 # Cleanup if the child failed starting.
C:\ProgramData\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
1015 env,
1016 os.fspath(cwd) if cwd is not None else None,
-> 1017 startupinfo)
1018 finally:
1019 # Child is launched. Close the parent's copy of those pipe
FileNotFoundError: [WinError 2] The system cannot find the file specified
您使用 pyexiftool
的方式要求 exiftool
在 $PATH
环境变量中列出的目录中可用。
打开 cmd
window,输入命令 exiftool
并点击 enter
。如果这也是 returns 一个 "file not found" 错误,那么
exiftool
未安装或- 安装
exiftool
的目录不在路径中
在情况 (2) 中,您可以在构造函数中提供 exiftool
可执行文件的完整路径。例如:
exiftool.ExifTool(r'C:\program files\exiftool\exiftool.exe')