-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Mac: generated executable throws "Error loading Python lib" for any program #5062
Comments
@Legorooj I can have a look over the coming days |
From my first look, I haven't managed to recreate your problem so far.
I will continue to look into it. |
This might be a code signing related issue https://stackoverflow.com/questions/42133980/ios-code-signature-invalid-required-code-signature-missing |
@arosiclair pinging |
Upgraded to Catalina macOS 10.15.6 but running the excutable still produces the same error:
Not familiar with code signing but this is the error the CLI reports for the binary in question:
|
To me this seems to resemble this open issue #2439 |
Try adding the |
I just tested @arosiclair 's code, because I have the same error with another application.
I then followed this recipe to add a code-sign (using the deep argument) Recipe OSX Code Signing.
app = BUNDLE(exe,
name='Sandbox.app',
icon=None,
bundle_identifier=None,
info_plist={
'NSPrincipalClass': 'NSApplication',
'NSAppleScriptEnabled': False,
'CFBundleDocumentTypes': [
{
'LSItemContentTypes': ['com.example.myformat'],
'LSHandlerRank': 'Owner'
}
]
},
)
|
I am also hitting this issue. I have traced it down to the fact that executables built in onefile mode with Python 3.7.6 work correctly, but built with any higher version of Python (3.7.7, 3.7.8, 3.7.9) does not work and throws the invalid code signature error. I have confirmed this by building with multiple version on a mac with OS 10.15.6. I also tried multiple versions of PyInstaller 3.5, 3.6, 4.0 all yielding the same results. Found this thread which was very helpful: http://pyinstaller.47505.x6.nabble.com/Help-needed-Error-loading-Python-lib-td2872.html#a2873 |
From 3.7.7 on and from 3.8.2 on, the macOS installer packages from python.org are compatible with Gatekeeper requirements regarding code signing. The
This in turn causes the A possible work-around may be removing the signature from
This seems to do the trick for a |
I just downgraded from Python 3.7.7 to Python 3.7.6. I don't know the reason, but as @rokm said, I guess this is related to the recent addition of full Gatekeeper notarization on macOS binaries, (read on the changelog https://www.python.org/downloads/release/python-379/) On the macOS section, is wrote this: After reading this, I tested with homebrew python version and also didn't work ☹ |
I can confirm this behaviour and the workaround.
it works fine again (without having to sign anything)! |
I still have this issue even after downgrading to python 3.7.6 or using python 3.9.1, on MacOS 11.1 It seems to work on the mac that generates the app, but the dist doesn't work on any other mac machine. Error on usage: $ myscript
[60786] Error loading Python lib '/var/folders/yq/1y1vcbld4sz5t00d3qctmsc80000gn/T/_MEIncCe0Z/Python': dlopen: dlopen(/var/folders/yq/1y1vcbld4sz5t00d3qctmsc80000gn/T/_MEIncCe0Z/Python, 10): Symbol not found: _preadv
Referenced from: /var/folders/yq/1y1vcbld4sz5t00d3qctmsc80000gn/T/_MEIncCe0Z/Python (which was built for Mac OS X 11.1)
Expected in: /usr/lib/libSystem.B.dylib
in /var/folders/yq/1y1vcbld4sz5t00d3qctmsc80000gn/T/_MEIncCe0Z/Python |
@dsoegijono If you take a closer look at your error message, you'll see that it's a different issue. You are using python that was build with minimum macOS version set to 11.1, so the Python shared library collected from that will not load on any earlier version of macOS. I suppose you are using a custom python build, because official python.org builds have minimum version still set to 10.9 (even the new macos11 variant of python 3.9.1). |
Thanks @rokm would it be better if I create a separate issue then? I'm not sure why the minimum version is set to 11.1
I installed via pyenv install 3.9.1
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.1.tar.xz...
-> https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tar.xz
Installing Python-3.9.1...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.9.1 to /Users/daphne/.pyenv/versions/3.9.1 |
That I've no idea how much you can influence it from So either you'll need to switch to python version that's backwards compatible (like python.org builds), or use an older version of macOS as your build system. |
Maybe setting the |
Hi there I have a similar problem, but not the same.
Has anyone else come across this problem too? |
Manually signing |
Thank you for quick response @rokm ! |
You can (re)sign problematic files one by one, you can try listing them based on extension ( Depending on your application type (i.e., if it is not pure CLI program), you could instead try generating .app bundle and sign that recursively using |
Description of the issue
The generated Mac executable for any program even a basic basic "Hello, World" script does not execute correctly. Using --onedir, --onefile, and --noupx does not remedy this issue.
Context information (for bug reports)
pyinstaller --version
:PyInstaller: 4.0.dev0
(same issue in 3.6 release)--noupx
or setupx=False
in your .spec-file--debug
topyi-makespec
orpyinstaller
or useEXE(..., debug=1, ...)
in your .spec file.A minimal example program which shows the error
A bash script that will generate this issue:
Stacktrace / full error message
The executable error:
The full log from the above script
The text was updated successfully, but these errors were encountered: