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

lib-dynload/_ssl.so, 2): Library not loaded: @rpath/libssl.1.1.dylib #308

Open
gauthierbuttez opened this issue Sep 12, 2020 · 2 comments
Open

Comments

@gauthierbuttez
Copy link

Environment:

Mac OS X Catalina 10.15.6
Python 8

Hi,
I try to compile my python code with py2app.
Here is my setup.py:

"""
This is a setup.py script generated by py2applet

Usage:
    python setup.py py2app
"""

from setuptools import setup

APP = ['MyApp.py']
APP_NAME = "MyApp"
DATA_FILES = [ 'necessary_files/create_db.sql',
                    'necessary_files/fra.traineddata',
                    'necessary_files/ui.txt',
                    'MyApp_Install.sh',
                    'necessary_files/assets',
                    'necessary_files/cgi',
                    'necessary_files/selenium',
                    'ui/']
OPTIONS = {
    'iconfile': 'MyApp_icon.icns',
    'packages': ['requests', 'selenium'],
    'plist': {
        'CFBundleName': APP_NAME,
        'CFBundleDisplayName': APP_NAME,
        'CFBundleGetInfoString': "Marketing Bot",
        'CFBundleIdentifier': "com.cff.MyApp",
        'CFBundleVersion': "0.0.2",
        'CFBundleShortVersionString': "0.0.2",
        'NSHumanReadableCopyright': u"Copyright © 2020, CFF, All Rights Reserved"}
        }

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

When compilation is done, I run my app with this command in terminal in order to see error and I get this:

/Users/gauthierbtz/Dropbox/cff/Python/MyApp_0002_FINAL/dist/MyApp.app/Contents/MacOS/MyApp ; exit;
(base) gauthierbtz@MacBook-de-Gauthier ~ % /Users/gauthierbtz/Dropbox/cff/Python/MyApp_0002_FINAL/dist/MyApp.app/Contents/MacOS/MyApp ; exit;
Traceback (most recent call last):
  File "/Users/gauthierbtz/Dropbox/cff/Python/MyApp_0002_FINAL/dist/MyApp.app/Contents/Resources/__boot__.py", line 115, in <module>
    _run()
  File "/Users/gauthierbtz/Dropbox/cff/Python/MyApp_0002_FINAL/dist/MyApp.app/Contents/Resources/__boot__.py", line 84, in _run
    exec(compile(source, path, "exec"), globals(), globals())
  File "/Users/gauthierbtz/Dropbox/cff/Python/MyApp_0002_FINAL/dist/MyApp.app/Contents/Resources/MyApp.py", line 29, in <module>
    import mymodules
  File "<frozen zipimport>", line 259, in load_module
  File "mymodules.pyc", line 5, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "ssl.pyc", line 98, in <module>
ImportError: dlopen(/Users/gauthierbtz/Dropbox/cff/Python/MyApp_0002_FINAL/dist/MyApp.app/Contents/Resources/lib/python3.8/lib-dynload/_ssl.so, 2): Library not loaded: @rpath/libssl.1.1.dylib
  Referenced from: /Users/gauthierbtz/Dropbox/cff/Python/MyApp_0002_FINAL/dist/MyApp.app/Contents/Resources/lib/python3.8/lib-dynload/_ssl.so
  Reason: image not found
2020-09-12 22:15:58.769 MyApp[81463:1290389] MyApp Error

So I searched for solution in Google and tried some stuff.

I reinstall openssl with command "brew reinstall openssl"

I added this in my .zshrc file:

export PATH="/usr/local/opt/openssl\@1.1/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl\@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl\@1.1/include"

I restart my terminal.

I typed these lines in my terminal:

export LDFLAGS="-L/usr/local/opt/openssl\@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl\@1.1/include"

And I still get the same error message. I don't know what else to do.

I uploaded here the logs of the compilation if it can help. I didn't see anything weird:
https://github.com/gauthierbuttez/public/blob/master/logs_py2app.txt

Can someone help me please?

@ronaldoussoren
Copy link
Owner

The environment variables you added won't have an effect, py2app doesn't look at those (and neither does the generated app bundle).

The problem you are running into is that py2app (or rather the macholib library used by py2app) does not support "@rpath". Because of this not all shared libraries used by your application are copied in the app bundle.

A workaround for this is to use the python.org installer for Python and install Python packages using pip, although I don't know how realistic this would be for your setup as not all software is available that way.

@ronaldoussoren
Copy link
Owner

A recent PR adds support for @rpath to the loader executable in the generated application bundle, but does not (yet) add support for copying files on the @rpath to the application bundle.

I'm not sure when I'll get around to doing that, this main blocker is that I don't have homebrew or another python installation using @rpath on my machine. In the end this will require an extension to the code added in 2fde755.

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

2 participants