Farisk1
Farisk1

Reputation: 61

Pyinstaller giving error ("Error loading Python ... no suitable image found")

I have this is issue with pyinstaller on Mac that gives this error when I click on the created executable:

[9888] Error loading Python lib '/Users/Faris/Downloads/as5/dist/startscreen/Python': dlopen: dlopen(/Users/Faris/Downloads/as5/dist/startscreen/Python, 10): no suitable image found.  Did find:
    /Users/Faris/Downloads/as5/dist/startscreen/Python: code signature invalid for '/Users/Faris/Downloads/as5/dist/startscreen/Python'

This is a GUI application that uses PIL and 4 PNG files. How can I fix this?

Upvotes: 6

Views: 4588

Answers (4)

SoleSoul
SoleSoul

Reputation: 368

I found how to make it work. After the Python lib is in your dist folder, run:

codesign -f -s - Python

Then run the application.

I have a theory what the problem is but I'm not sure. I think the Python lib is signed, but when PyInstaller moves it from its original place, the signature verification fails.

What the command does is to replace the signature with an ad-hoc signature, which allows you to run the application locally, but probably doesn't count as a signature for distribution. I can't say I fully understand it.

Before you ship the application you probably want to replace the ad-hoc signature with a proper signature.

Upvotes: 1

Martí Climent
Martí Climent

Reputation: 557

Take note that on macOS, python3.7.7 or + and python3.8.3 or + are giving the same error, because of the addition of a full-notarization signing for python to avoid gatekeeper alerts.

Just install Python 3.7.6 or Python 3.8.2

Upvotes: 1

jun1okamura
jun1okamura

Reputation: 11

I had resolved the same trouble with the following:

  1. pip3 uninstall pyinstaller
  2. brew reinstall python
  3. brew install pyinstaller

Upvotes: 1

Martí Climent
Martí Climent

Reputation: 557

Try to install lastest dev version from PyInstaller:

pip3 install --upgrade https://github.com/pyinstaller/pyinstaller/tarball/develop

or

pip install --upgrade https://github.com/pyinstaller/pyinstaller/tarball/develop

Upvotes: 0

Related Questions