Py2App在编译应用程序进行分发时不工作



我一直在尝试将我的python程序制作成一个应用程序,以便将其分发到其他计算机。我已经尝试过使用Py2App。

当我在Alias模式下制作应用程序后运行程序时,程序和GUI工作得很好:

python setup.py py2app -A

然而,当我使用以下命令制作用于分发的应用程序时:

python setup.py py2app

我在终端的最后收到了红色的文本:

Modules not found (conditional imports):
* Cookie (requests.compat)
* Image (/Users/Febin.J/Documents/Projects/Python Projects/Planner Builder/venv/lib/python3.8/site-packages/py2app/recipes/PIL/prescript.py)
* Numeric (numpy.distutils.system_info)
* OpenSSL.crypto (urllib3.contrib.pyopenssl)
* PyQt6 (PIL.ImageQt)
* PyQt6.QtGui (PIL.ImageQt)
* PySide2 (PIL.ImageQt)
* PySide2.QtGui (PIL.ImageQt)
* PySide6 (PIL.ImageQt)
* PySide6.QtGui (PIL.ImageQt)
* Queue (urllib3.util.queue)
* _manylinux (pkg_resources._vendor.packaging._manylinux)
* _pytest (numpy.typing.tests.test_typing)
* _ufunc (numpy.typing)
* ccompiler_opt (numpy.distutils.tests.test_ccompiler_opt, numpy.distutils.tests.test_ccompiler_opt_conf)
* cffi (PIL.ImageTk)
* checks (numpy.core.tests.test_cython)
* com (pkg_resources._vendor.appdirs)
* com.sun.jna (pkg_resources._vendor.appdirs)
* com.sun.jna.platform (pkg_resources._vendor.appdirs)
* cookielib (requests.compat)
* cryptography (requests)
* cryptography.x509.extensions (urllib3.contrib.pyopenssl)
* defusedxml (openpyxl.xml)
* defusedxml.ElementTree (openpyxl.xml.functions)
* lxml.etree (openpyxl.xml, openpyxl.xml.functions)
* mem_policy (numpy.core.tests.test_mem_policy)
* nose (numpy.testing._private.decorators, numpy.testing._private.utils, numpy.testing.tests.test_doctesting)
* nose.plugins (numpy.testing._private.nosetester)
* nose.plugins.builtin (numpy.testing._private.nosetester)
* numarray (numpy.distutils.system_info)
* numpy.testing.noseclasses ()
* numpy_distutils (numpy.f2py.diagnose)
* numpy_distutils.command.build_flib (numpy.f2py.diagnose)
* numpy_distutils.command.cpuinfo (numpy.f2py.diagnose)
* numpy_distutils.cpuinfo (numpy.f2py.diagnose)
* numpy_distutils.fcompiler (numpy.f2py.diagnose)
* pandas (xlwings.conversion.numpy_conv)
* psutil._psutil_windows ()
* pytest (numpy._pytesttester, numpy.testing._private.utils)
* scipy (numpy.testing._private.nosetester)
* test (multiprocessing.util)
* urllib2 (requests.compat)
* urlparse (requests.compat)
* win32com.client (xlwings)
* win32com.shell (pkg_resources._vendor.appdirs)
* win32pdh (numpy.testing._private.utils)

之后,当我试图从Finder打开应用程序时(进入dist文件夹并双击.app(,我收到Finder的消息,说应用程序意外退出。当从终端运行时,我得到:

Abort trap: 6

我使用的是Python 3.8.9。我使用PyQt5(v5.15(作为我的GUI,我使用的是Mac(MacOS 12.1(

我的setup.py文件是这样的:

"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['mainwindow.py']
DATA_FILES = ["both_bins.png", "both_holidays.png", "green_bin.png", "s_holidays.png", "u_holidays.png", "important_dates.db"]
OPTIONS = {
"iconfile":"logo.icns",
"plist": {
'CFBundleName': "Planner Builder",
'CFBundleDisplayName': "Planner Builder",
'CFBundleVersion': "1.1",
'CFBundleShortVersionString': "1.1"
}
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)

你能帮我解决这个问题吗?

我是py2app的新手,不是专家。根据我有限的经验,有一件事需要尝试,特别是如果错误列表似乎与您的实际项目无关,那就是为您的项目创建所需的最简单的环境,然后在其中运行py2app。对于我的项目,我是在一个相对臃肿的环境中开始的,从py2app中得到了源源不断的神秘错误。当我在最小的环境下重新开始时,它运行得很顺利。

最新更新