smarnach / pyexiftool

a Python library to communicate with an instance of Phil Harvey's excellent ExifTool command-line application.
Other
270 stars 111 forks source link

pyexiftool resulting in OSError: [Errno 8] Exec format error #37

Open JonathanRoth13 opened 2 years ago

JonathanRoth13 commented 2 years ago

i encountered the following error :

Traceback (most recent call last):
  File "yeah.py", line 21, in <module>
    with exiftool.ExifTool("/usr/local/lib/python2.7/dist-packages/exiftool.py") as et:
  File "/usr/local/lib/python2.7/dist-packages/exiftool.py", line 191, in __enter__
    self.start()
  File "/usr/local/lib/python2.7/dist-packages/exiftool.py", line 174, in start
    stderr=devnull)
  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error

the way i got around this was by modifying start()

 def start(self):
        """Start an ``exiftool`` process in batch mode for this instance.

        This method will issue a ``UserWarning`` if the subprocess is
        already running.  The process is started with the ``-G`` and
        ``-n`` as common arguments, which are automatically included
        in every command you run with :py:meth:`execute()`.
        """
        if self.running:
            warnings.warn("ExifTool already running; doing nothing.")
            return
        with open(os.devnull, "w") as devnull:
            self._process = subprocess.Popen(
                [self.executable, "-stay_open", "True",  "-@", "-",
                 "-common_args", "-G", "-n"],
                stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                stderr=devnull,shell=True)
        self.running = True

see https://askubuntu.com/questions/801493/python-subprocess-call-not-working-as-expected

sylikc commented 2 years ago

something is weird about your usage of Exiftool... the constructor is supposed to point to the executable, yet you have it pointed to the distribution? I don't think it's the linked problem... something else going on