Skip to content
Advertisement

Issues compiling mediapipe with pyinstaller on macos

I have issues compiling a project with mediapipe via pyinstaller on macos

so far I tried:

JavaScript

The .app does not open, and if I try the unix exec, I get

JavaScript

I work with conda, my env is in python 3.8, mediapipe 0.8.5 and OSX 10.15.7

Thanks in advance

Advertisement

Answer

I ran into this issue too and just figured it out a few minutes ago — so far, I’m getting around it the manual way, but I’m sure there’s an idiomatic way to do it in pyinstaller using the spec file and the data imports. For this answer, I’m assuming you’re not using the --onefile option for pyinstaller, but rather creating the binary in a single folder.

That said, the answer is to cp -r the modules directory from your mediapipe installed in the virtual environment (or wherever you installed the initial mediapipe package, e.g. /virtualenvs/pose_record-2bkqEH7-/lib/python3.9/site-packages/mediapipe/modules) into your dist/main/mediapipe directory. This will enable your bundled mediapipe library to access the binarypb files which I believe contain the graphs and weights for the pose detection algorithm.

UPDATE: I have figured out a more idiomatic pyinstaller way of getting it to run. In the .spec file generated by pyinstaller, you’re able to automatically add files in the following way:

At the top of the file, under the block_cipher = None, add the following function:

JavaScript

Then, after the following lines:

JavaScript

add the following lines which utilize the native Tree class to create a TOC for the binary:

JavaScript

Once added, you can run the compile command from the CLI, e.g.: pipenv run pyinstaller --debug=all main.spec --windowed --onefile

This allowed me to build an executable that functioned for mediapipe.

User contributions licensed under: CC BY-SA
12 People found this is helpful
Advertisement