尝试检索.jpg EXIF数据时不断返回“找不到文件”

问题描述

我正在尝试使用PyExifTool检查给定图像的EXIF数据。我使用的是github support documents和另一个StackOverflow resource中几乎相同的副本。

这是我的代码

import exiftool
import os,errno
files = ["/Users/username/Pictures/testimage.jpg"]

with exiftool.ExifTool() as et:
    Metadata = et.get_tag('DateCreated',files)
    print(Metadata)

然后我收到了相当多的错误消息。由于我对编码非常陌生,因此我正在努力解决此响应。

Traceback (most recent call last):
  File "/Users/username/Documents/test.py",line 7,in <module>
    with exiftool.ExifTool() as et:
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exiftool.py",line 191,in __enter__
    self.start()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exiftool.py",line 170,in start
    self._process = subprocess.Popen(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py",line 854,in __init__
    self._execute_child(args,executable,preexec_fn,close_fds,File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py",line 1702,in _execute_child
    raise child_exception_type(errno_num,err_msg,err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'exiftool'

大概,这里的关键信息是:

FileNotFoundError: [Errno 2] No such file or directory: 'exiftool'

除了我不太明白我被告知的是什么? ExifTool应该是一种工具,我并不是故意尝试将其作为文件或目录来访问。

我可以确定ExifTool是否已正确安装,因为如果在命令行中运行...

#bash:~

$ exiftool /Users/username/Pictures/testimage.jpg

... ExifTool返回测试图像的所有Exif数据,包括完整的“创建日期”字段。顺便说一句,这也证实了我的路径是正确的。


编辑1:根据三元组的要求提供其他信息

(当我提供错误的信息时,请原谅我的无知)

- 如何运行脚本? ->我只是在.py文档中有该代码段,然后在我的空闲shell中运行?

- 在Bash中运行type -all exiftool

exiftool is /usr/local/bin/exiftool
exiftool is /usr/local/bin/exiftool

(是的,它确实两次给出相同的结果)

- 在空闲状态下运行print(os.environ['PATH'])

/usr/bin:/bin:/usr/sbin:/sbin

编辑2:有关Tripleee查询的其他疑难解答

- 在Bash中运行type -all exiftool给出了两条路径。

exiftool is /usr/local/bin/exiftool
exiftool is /usr/local/bin/exiftool

->我使用在其他地方找到的一些代码来尝试解决此问题。

PATH=$(printf "%s" "$PATH" | awk -v RS=':' '!a[$1]++ { if (NR > 1) printf RS; printf $1 }')

现在在Bash中运行type -all exiftool仅提供...

exiftool is /usr/local/bin/exiftool

在我打开新的终端窗口/标签之前,问题将返回该点。

- 如何运行脚本?

现在我打开终端并输入IDLE3,以便从提示符而不是通过快捷栏上的图标打开它。

这给出了一个新的错误...

Traceback (most recent call last):
  File "/Users/username/Documents/test.py",line 9,in <module>
    Metadata = et.get_tag('Date Created',files)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exiftool.py",line 325,in get_tag
    return self.get_tag_batch(tag,[filename])[0]
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exiftool.py",line 312,in get_tag_batch
    data = self.get_tags_batch([tag],filenames)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exiftool.py",line 291,in get_tags_batch
    return self.execute_json(*params)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exiftool.py",line 252,in execute_json
    return json.loads(self.execute(b"-j",*params).decode("utf-8"))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/exiftool.py",line 108,in fsencode
    return filename.encode(encoding,errors)
AttributeError: 'list' object has no attribute 'encode'

关键区别在于:

AttributeError: 'list' object has no attribute 'encode'

编辑3:有关Tripleee查询的其他疑难解答

- 发现我已经将nano .bash_profile添加到了.bash_profile的末尾。

->此内容删除

- 在空闲状态下运行print(os.environ['PATH']),但现在使用IDLE3

/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/fsl/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin~/.bash_profile

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...