1

我已经安装了 PyExifTool ( https://smarnach.github.io/pyexiftool/ )。安装成功。但是,当我尝试运行那里提供的示例代码时:

import exiftool

files = ["test.jpg"]
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"]))

我收到此错误:

Traceback (most recent call last):
  File "extract_metadata_03.py", line 5, in <module>
    metadata = et.get_metadata_batch(files)
  File "c:\Python38\lib\site-packages\exiftool.py", line 264, in get_metadata_batch
    return self.execute_json(*filenames)
  File "c:\Python38\lib\site-packages\exiftool.py", line 256, in execute_json
    return json.loads(self.execute(b"-j", *params).decode("utf-8"))
  File "c:\Python38\lib\site-packages\exiftool.py", line 227, in execute
    inputready,outputready,exceptready = select.select([fd],[],[])
OSError: [WinError 10093] Either the application has not called WSAStartup, or WSAStartup failed

我已经尝试在我的路径中使用exiftool.exe版本 11.91 独立 Windows 可执行文件(来自https://exiftool.org/)以及使用 Oliver Betz 的 ExifTool Windows 安装程序(https://oliverbetz.de/pages/Artikel/ExifTool安装 exiftool -for-Windows )

我尝试了两个具有相同行为的单独 Python 安装(Python 3.8 和 Python 2.7)。

对此的任何帮助或故障排除建议将不胜感激。

4

1 回答 1

2

您收到错误是因为 exiftool.py 中使用的 select.select() 与 Windows 不兼容。要解决这个问题,您可以手动将以下内容添加到 exiftool.py:

if sys.platform == 'win32':
    # windows does not support select() for anything except sockets
    # https://docs.python.org/3.7/library/select.html
    output += os.read(fd, block_size)
else:
    # this does NOT work on windows... and it may not work on other systems... in that case, put more things to use the original code above
    inputready,outputready,exceptready = select.select([fd],[],[])
    for i in inputready:
        if i == fd:
            output += os.read(fd, block_size)

来源:https ://github.com/sylikc/pyexiftool/commit/03a8595a2eafc61ac21deaa1cf5e109c6469b17c

于 2020-06-19T09:24:39.023 回答