运用 Py2app 库打包 MacOS 的程序,启动报错 LaunchError,请问需要怎么生成 PlugIns 的文件

最近用Python写了一些脚本,Python本地运行代码没问题。运用Py2app库打包出来MacOS的程序启动会报错LaunchError。

打包步骤
  1. 运行pip3 install -U py2app
  2. 将自己的代码脚本放到一个目录下,进到该目录运行 python setup.py install
  3. 运行py2applet --make-setup Main.py
  4. 运行python setup.py py2app -A ,打出的包启动报错LaunchError;清掉build、dist等构建出来的目录,重新运行python setup.py py2app,打出的包启动报错LaunchError。 这里加-A 会指示 py2app 构建一个应用程序包,该包就地使用您的源文件和数据文件。不加 “应用程序是独立的,因此每次py2app 更改任何源代码、数据文件、选项等时都必须再次运行该命令。”
Terminal调试报错日志
默认 lsd    Non-fatal error enumerating at <private>, continuing: Error Domain=NSCocoaErrorDomain Code=260 "未能打开文件“PlugIns”,因为它不存在。" UserInfo={NSURL=PlugIns/ -- file:///Users/xxxxx/xxxxx.app/Contents/, ...., NSUnderlyingError=0x7f973044b690 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
默认 loginwindow    -[PersistentAppsSupport applicationReady:] | App: BatchInstaller, ready, updating active tracking timer
默认 oginwindow    -[ApplicationManager checkInAppContext:refCon:eventData:] |      checked in app : .....
默认 distnoted    register name: com.apple.sharedfilelist.change object: com.apple.LSSharedFileList.ApplicationRecentDocuments/org.pythonmac.unspecified.batch
环境
  1. Python 3.7
  2. Py2app 26.1
  3. MacOS系统:在MacOS10.1和M1上都试了,都会启动报错,报错日志一样

Py2app官网:https://py2app.readthedocs.io/en/latest/tutorial.html#clean-up-your-build-directories

setup.py文件内容:


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

Usage:
    python setup.py py2app
"""

from setuptools import setup

APP = ['Main.py']
DATA_FILES = ['Install.py','Device.py']
OPTIONS = {'argv_emulation': True,'iconfile':'BtiFj.ico'}

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

```

你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答


本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。


因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。