Python OSError异常';[Errno 2]没有这样的文件或目录';使用子流程时,请检查_output()
我正在尝试使用subprocess执行ExifTool read命令从jpg文件读取元信息 调用get_dimensions()的函数首先创建文件,将其文件路径存储在file_name中——我仔细检查了,它确实存在于它应该存在的地方——并最终调用get_dimensions()。在此函数中调用subprocess.check_output()始终会引发操作错误。顺便说一下,我正在Python2.7.10上运行pytestPython OSError异常';[Errno 2]没有这样的文件或目录';使用子流程时,请检查_output(),python,python-2.7,subprocess,exiftool,Python,Python 2.7,Subprocess,Exiftool,我正在尝试使用subprocess执行ExifTool read命令从jpg文件读取元信息 调用get_dimensions()的函数首先创建文件,将其文件路径存储在file_name中——我仔细检查了,它确实存在于它应该存在的地方——并最终调用get_dimensions()。在此函数中调用subprocess.check_output()始终会引发操作错误。顺便说一下,我正在Python2.7.10上运行pytest def get_dimensions(self, file_name):
def get_dimensions(self, file_name):
exiftool = subprocess.check_output(['exiftool', '-j', file_name])
exif = json.loads(exiftool)[0]
width, height = (exif.get('ImageWidth', 0), exif.get('ImageHeight', 0))
return (width, height)
错误是:
Exception has occurred: OSError
[Errno 2] No such file or directory
File "/Users/derek/m-app-tests/tests/TestUtils/client_api.py", line 428, in get_dimensions
exiftool = subprocess.check_output(['exiftool', '-j', file_name])
原来我没有安装exiftool。原来我没有安装exiftool