简体   繁体   中英

py2app not including Python in built .app

I'm trying to build a distributable Python application with py2app. The built application executes without any issues on my device, however, if trying to run it on a different device I face this error

Dyld Error Message:
  Library not loaded: /Library/Frameworks/Python.framework/Versions/3.8/Python
  Referenced from: /Users/USER/Downloads/*/main
  Reason: image not found

I have tried running py2app from venv and not also by specifying python3.8 when running py2app.

What I have noticed that the issue only arrises when attempting to run the.app file, if I run main.app/Contents/MacOS/main via the terminal it works on other devices.

My setup.py file looks like this

from setuptools import setup

APP = ['main.py']
DATA_FILES = ['utils.py']
OPTIONS = {}

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

Not facing any issues with imports such as Selenium.

So after spending a few days on the issue and trying out different tools such as cx_freeze and pyinstaller I have managed to find the answer by accident.

When attempting to run the application on other devices - it failed. The thing is that when I tested it, I always tried to run the application from the Downloads folder, after moving it to any other directory, it works!

Hopefully this comes to use to anyone else struggling with the same issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM