Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documention with pyinstaller notes #100

Open
Josh-Voyles opened this issue Nov 21, 2024 · 0 comments
Open

Update documention with pyinstaller notes #100

Josh-Voyles opened this issue Nov 21, 2024 · 0 comments

Comments

@Josh-Voyles
Copy link

Josh-Voyles commented Nov 21, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant