Skip to content

Update documention with pyinstaller notes #100

@Josh-Voyles

Description

@Josh-Voyles

It may be worth updating the documentation to include additional notes about pyinstaller and how the path changes.

Problem

Despite exiftool being in my system path, when my pyqt application is compiled with pyinstaller and the .app executable is ran, shutil.which(new_executable) on line 374 of exiftool.py will return None.

Personal Solution (my_metatool.py)

I created a function that checks hard-coded paths on the system and assigned it to self._exiftool_path variable.

    # handles unix paths
    def _get_exiftool_path(self) -> str:
        possible_paths = [
            "/opt/homebrew/bin/exiftool",
            "/usr/local/bin/exiftool",
        ]
        for path in possible_paths:
            if os.path.exists(path):
                return path
        return "exiftool"

Then, I passed self._exiftool_path as a parameter to ExiftoolToolHelper() in a separate function.

    def retreive_metadata(self, path, selected_extension) -> dict:
        if files := self._load_files(path, selected_extension):
            with ExifToolHelper(executable=self._exiftool_path) as et:
                tags = et.get_tags(files[0], tags=list(self.meta_fields.keys()))
                for key, value in tags[0].items():
                    key = key.split(":")
                    if len(key) > 1 and key[1] in self.meta_fields:
                        self.meta_fields[key[1]] = value
                et.terminate()
        return self.meta_fields

Note: The unix executable generated by pyinstaller works fine without explicitly declaring the path. It's just the bundled .app executable that presents the problem.

This took me several hours to figure out a solution, so I wanted to preset it as an opportunity to save someone else some time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions