奇怪的py2app问题:在别名模式下作为Python脚本和app工作,但不作为冻结/捆绑/部署应用程序

时间:2015-12-17 18:44:20

标签: python dependencies setuptools py2app easygui

基本问题:

我有一个Python脚本,它应该将服务器列表写入Excel文件。当它作为Python脚本运行时,它可以工作。当我在py2app的别名模式下运行它时,它也可以工作。

然而,当我构建一个可再发行的单文件Mac应用程序(在these instructions之后)时,一切正常 - 除了编写服务器的名称而不是写一个数字。

到底发生了什么事?

更多细节(不确定相关内容):

输出错误:

  • 这些数字将作为文本字符串写入Excel文件。
  • 有趣的是,这些数字通常等于或几乎等于服务器名称的长度(字符数)。

脚本的工作原理:

  • 该脚本获取Excel文件中的电子邮件地址列表,用户通过easygui fileopenbox选择该文件,通过MX记录获取电子邮件服务器,然后将该数据写入同一Excel文件。
  • 它使用(进口)openpyxl,easygui(使用Tkinter),sys,dns.resolver和optparse。

在使用" python setup.py py2app"后,我在终端中看到以下内容:命令:

Modules not found (unconditional imports):
 * ElementC14N (xml.etree.ElementTree)
 * PIL (easygui.boxes.utils)
 * PIL.ImageTk (openpyxl.drawing.image)
 * __builtin__.open (repr)
 * __main__.__requires__ (pdb)
 * _imp (pkg_resources)
 * _weakref.CallableProxyType (_weakrefset)
 * _weakref.ProxyType (_weakrefset)
 * _weakref.ReferenceType (_weakrefset)
 * _weakref.getweakrefcount (_weakrefset)
 * _weakref.getweakrefs (_weakrefset)
 * _weakref.proxy (_weakrefset)
 * _winreg.CloseKey (urllib)
 * _winreg.HKEY_LOCAL_MACHINE (urllib)
 * _winreg.OpenKeyEx (urllib)
 * _winreg.QueryValueEx (urllib)
 * errno.EINVAL (os)
 * errno.ENOENT (os)
 * java.System (java.lang)
 * nt._getfullpathname (os)
 * nt._isdir (os)
 * org (copy, org.python.core)
 * org.PyStringMap (org.python)
 * org.python (copy, pickle)
 * org.python.core (pickle)
 * org.python.core.PyStringMap (copy)
 * packaging (pkg_resources)
 * packaging.specifiers (pkg_resources)
 * pwd.getpwnam (distutils.util)
 * sys.exc_info (os)
 * sys.getwindowsversion (os)
 * sys.modules (os)
 * sys.py3kwarning (os)
 * tests (openpyxl.reader.excel)
 * thread._local (collections)
 * thread.allocate_lock (collections)
 * thread.stack_size (collections) [scroll down for more]
 * tkinter (easygui.boxes.utils)
 * tkinter.filedialog (easygui.boxes.utils)
Modules not found (conditional imports):
 * Image (openpyxl.drawing.image)
 * PIL (openpyxl.drawing.image)
 * _md5 (hashlib)
 * _sha (hashlib)
 * _sha256 (hashlib)
 * _sha512 (hashlib)
 * importlib.machinery (pkg_resources)
 * java (platform)
 * java.lang (platform)
 * riscospath (os)
 * urllib.parse (pkg_resources)

设置文件如下所示:

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

Usage:
    python setup.py py2app
"""

from setuptools import setup

APP = ['CheckEmailServers2.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True}

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

我的系统和软件:

  • Python 2.7.11(v2.7.11:6d1b6a68f775,2015年12月5日,12:54:16)[dclwin上的GCC 4.2.1(Apple Inc. build 5666)(第3点)]
  • OS X El Capitan 10.11.2,2.9 GHz Intel Core i7

0 个答案:

没有答案