2

Basic problem:

I have a Python script that's supposed to write a list of servers to an Excel file. When running it as a Python script, it works. When I run it in py2app's alias mode, it also works.

However, when I build a redistributable single-file Mac app (following these instructions), everything works -- except that instead of writing the names of servers, it writes a number.

What the heck is going on??

More details (not sure what's relevant):

The wrong output:

  • The numbers are written to the Excel file as text strings.
  • Interestingly, the numbers are typically equal or nearly equal to the length of the server name (number of characters).

How the script works:

  • The script takes a list of email addresses in an Excel file that the user selects via an easygui fileopenbox, gets email servers via MX record, then writes that data to the same Excel file.
  • It uses (imports) openpyxl,easygui (which uses Tkinter),sys,dns.resolver, and optparse.

I see the following in Terminal after using the "python setup.py py2app" command:

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)

The setup file looks like this:

"""
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'],
)

My system and software:

  • Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 12:54:16) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
  • OS X El Capitan 10.11.2, 2.9 GHz Intel Core i7
JesseG
  • 238
  • 1
  • 9

0 Answers0