我安装了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我尝试过在我的path中使用exiftool.exe版本11.91独立的Windows可执行文件(来自https://exiftool.org/),以及使用Oliver的exiftool Windows (https://oliverbetz.de/pages/Artikel/ExifTool-for-Windows)安装ExifTool。
我尝试过两种不同的Python安装(Python3.8和Python2.7),它们具有相同的行为。
如能对此提供任何帮助或提出故障排除建议将不胜感激。
发布于 2020-06-19 09:24:39
您会得到错误,因为在select.select中使用的exiftool.py ()与exiftool.py不兼容。要解决这个问题,您可以手动将以下内容添加到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
https://stackoverflow.com/questions/60647891
复制相似问题