简体   繁体   English

使用 py2app 和 boto3 编译时,应用程序在启动时崩溃

[英]App crashes on launch when compiled with py2app and boto3 is included

I created a complex app that uses boto3.我创建了一个使用 boto3 的复杂应用程序。 It works fine when run from the command line.从命令行运行时它工作正常。 But when I try to compile it with py2app the application file is created, but it crashes on launch.但是当我尝试用 py2app 编译它时,应用程序文件被创建,但它在启动时崩溃。 I simplified it down to 2 files and found that it crashes when boto3 is included but runs fine when boto3 is not included.我将其简化为 2 个文件,发现在包含 boto3 时它会崩溃,但在不包含 boto3 时运行良好。

setup.py设置文件

import sys
from setuptools import setup

APP = ['hello.py']
OPTIONS = {'iconfile':'img/icon.icns',}
setup(
    app = APP,
    options = {'py2app': OPTIONS},
    setup_requires = ['py2app'],
)

hello.py你好.py

from tkinter import *
import boto3

root = Tk()

w = Label(root, text="Hello, world!")
w.pack()

root.mainloop()

I am using the latest of everything, python 3.7 on MacOS 10.14 and on 10.13.我正在使用最新的一切,MacOS 10.14 和 10.13 上的 python 3.7。

I use the command line:我使用命令行:

python3 setup.py py2app

When I compile including boto3 I get these errors from py2app.当我编译包含 boto3 时,我从 py2app 收到这些错误。 I can't find a way to install these modules with pip.我找不到用 pip 安装这些模块的方法。

Modules not found (unconditional imports):
 * OpenSSL (botocore.vendored.requests.packages.urllib3.contrib.pyopenssl, urllib3.contrib.pyopenssl)
 * OpenSSL.SSL (urllib3.contrib.pyopenssl)
 * Queue (botocore.vendored.requests.packages.urllib3.connectionpool)
 * Queue.Empty (urllib3.util.queue)
 * Queue.Full (urllib3.util.queue)
 * Queue.LifoQueue (urllib3.util.queue)
 * StringIO.StringIO (botocore.vendored.requests.packages.urllib3.packages.six, botocore.vendored.six, pkg_resources._vendor.six, six, urllib3.packages.six)
 * _abcoll (botocore.vendored.requests.packages.urllib3.packages.ordered_dict, urllib3.packages.ordered_dict)
 * backports.ssl_match_hostname (botocore.vendored.requests.packages.urllib3.packages.ssl_match_hostname, urllib3.packages.ssl_match_hostname)
 * botocore.vendored.six.moves (botocore.httpsession, botocore.vendored.six.moves.urllib.request) [module alias]
 * botocore.vendored.six.moves.http_client (botocore.vendored.six.moves.urllib, botocore.vendored.six.moves.urllib_parse) [module alias]
 * botocore.vendored.six.moves.urllib (botocore.utils) [module alias]
 * botocore.vendored.six.moves.urllib.request (botocore.utils) [module alias]
 * botocore.vendored.six.moves.urllib_parse (botocore.httpsession) [module alias]
 * com (com.sun.jna)
 * com.jna (com.sun)
 * com.sun (com.sun.jna.platform)
 * cryptography (cryptography, cryptography.hazmat.backends, cryptography.x509.extensions, urllib3.contrib.pyopenssl)
 * cryptography.hazmat (cryptography.hazmat.backends.openssl)
 * cryptography.hazmat.backends (cryptography.hazmat.backends.openssl.x509, urllib3.contrib.pyopenssl)
 * cryptography.hazmat.backends.openssl (urllib3.contrib.pyopenssl)
 * cryptography.hazmat.backends.openssl.backend (cryptography.hazmat.backends.openssl.x509)
 * cryptography.hazmat.backends.openssl.x509 (urllib3.contrib.pyopenssl)
 * cryptography.x509 (cryptography.hazmat, cryptography.x509, urllib3.contrib.pyopenssl)
 * cryptography.x509.UnsupportedExtension (cryptography, cryptography.x509.extensions)
 * dummy_thread (botocore.vendored.requests.packages.urllib3.packages.ordered_dict, urllib3.packages.ordered_dict)
 * httplib (botocore.vendored.requests.packages.urllib3.connection, botocore.vendored.requests.packages.urllib3.response)
 * httplib.HTTPConnection (botocore.compat, botocore.vendored.requests.packages.urllib3.response)
 * httplib.HTTPException (botocore.compat, botocore.vendored.requests.packages.urllib3.response)
 * httplib.HTTPResponse (botocore.vendored.requests.packages.urllib3.connection, botocore.vendored.requests.packages.urllib3.response)
 * itertools.izip (collections)
 * itertools.izip_longest (collections)
 * ndg (botocore.vendored.requests.packages.urllib3.contrib.pyopenssl, ndg.httpsclient.subj_alt_name)
 * ndg.SUBJ_ALT_NAME_SUPPORT (ndg.httpsclient)
 * ndg.httpsclient (botocore.vendored.requests.packages.urllib3.contrib.pyopenssl)
 * ndg.httpsclient.subj_alt_name (botocore.vendored.requests.packages.urllib3.contrib.pyopenssl)
 * ordereddict (botocore.compat, pkg_resources._vendor.pyparsing)
 * pyasn1 (botocore.vendored.requests.packages.urllib3.contrib.pyopenssl)
 * pyasn1.decoder (pyasn1.type)
 * pyasn1.type (botocore.vendored.requests.packages.urllib3.contrib.pyopenssl)
 * simplejson (botocore.vendored.requests.compat)
 * six.moves (dateutil.rrule, dateutil.tz.tz, dateutil.tz.win) [module alias]
 * six.moves._thread (dateutil.tz.win) [module alias]
 * six.moves.winreg (dateutil.rrule, dateutil.tz.tz)
 * thread (botocore.vendored.requests.packages.urllib3.packages.ordered_dict, urllib3.packages.ordered_dict)
 * urllib3.packages.six.moves (urllib3.connection, urllib3.connectionpool, urllib3.exceptions, urllib3.packages.six.moves, urllib3.packages.six.moves.urllib.parse, urllib3.response, urllib3.util.queue, urllib3.util.response) [module alias]
 * urllib3.packages.six.moves.http_client (urllib3.connection, urllib3.connectionpool, urllib3.exceptions, urllib3.packages.six.moves.http_client, urllib3.packages.six.moves.urllib, urllib3.util.queue) [module alias]
 * urllib3.packages.six.moves.queue (urllib3.packages.six.moves.http_client, urllib3.packages.six.moves.urllib, urllib3.response, urllib3.util.response) [module alias]
 * urllib3.packages.six.moves.urllib (urllib3.poolmanager, urllib3.request) [module alias]
 * urllib3.packages.six.moves.urllib.parse (urllib3.poolmanager, urllib3.request) [module alias]
 * urlparse (botocore.vendored.requests.packages.urllib3.poolmanager)
 * urlparse.parse_qs (botocore.vendored.requests.compat, botocore.vendored.requests.packages.urllib3.poolmanager)
 * urlparse.parse_qsl (botocore.vendored.requests.compat, botocore.vendored.requests.packages.urllib3.poolmanager)
 * urlparse.urldefrag (botocore.compat, botocore.vendored.requests.packages.urllib3.poolmanager)
 * urlparse.urlparse (botocore.vendored.requests.packages.urllib3.poolmanager)
 * urlparse.urlsplit (botocore.vendored.requests.packages.urllib3.poolmanager)
 * urlparse.urlunparse (botocore.compat, botocore.vendored.requests.packages.urllib3.poolmanager)
 * urlparse.urlunsplit (botocore.vendored.requests.compat, botocore.vendored.requests.packages.urllib3.poolmanager)
 * win32com (win32com)
 * win32com.shell (win32com.shell)
 * win32com.shellcon (win32com.shell)

Modules not found (conditional imports):
 * Cookie (botocore.vendored.requests.compat)
 * OpenSSL.crypto (urllib3.contrib.pyopenssl)
 * Queue (urllib3.util.queue)
 * StringIO (botocore.vendored.requests.compat, botocore.vendored.requests.packages.urllib3.packages.six, botocore.vendored.six, pkg_resources._vendor.six, six, urllib3.packages.six)
 * botocore.vendored.six.moves (botocore.httpsession, botocore.vendored.six.moves.urllib.request) [module alias]
 * com (pkg_resources._vendor.appdirs)
 * com.sun.jna (pkg_resources._vendor.appdirs)
 * com.sun.jna.platform (pkg_resources._vendor.appdirs)
 * cookielib (botocore.vendored.requests.compat)
 * cryptography.x509.extensions (urllib3.contrib.pyopenssl)
 * email.Utils ()
 * httplib (botocore.compat)
 * simplejson (botocore.compat)
 * urllib2 (botocore.vendored.requests.compat)
 * urlparse (botocore.compat, botocore.vendored.requests.compat)
 * win32com (pkg_resources._vendor.appdirs)
 * win32com.shell (pkg_resources._vendor.appdirs)

When I compile without boto3 I get these errors, and the app works:当我在没有 boto3 的情况下编译时出现这些错误,并且该应用程序可以正常工作:

Modules not found (unconditional imports):
 * com (com.sun.jna)
 * com.jna (com.sun)
 * com.sun (com.sun.jna.platform)
 * ordereddict (pkg_resources._vendor.pyparsing)
 * win32com (win32com)
 * win32com.shell (win32com.shell)
 * win32com.shellcon (win32com.shell)

Modules not found (conditional imports):
 * StringIO (pkg_resources._vendor.six)
 * com (pkg_resources._vendor.appdirs)
 * com.sun.jna (pkg_resources._vendor.appdirs)
 * com.sun.jna.platform (pkg_resources._vendor.appdirs)
 * win32com (pkg_resources._vendor.appdirs)
 * win32com.shell (pkg_resources._vendor.appdirs)

But according to py2app's developer these warnings aren't very important但是根据 py2app 的开发人员的说法, 这些警告并不是很重要

I highlighted the only error that is different between the two programs on the console but isn't very helpful:我强调了控制台上两个程序之间唯一不同但不是很有帮助的错误:

在此处输入图片说明

I've read through StackOverflow thoroughly, but this is also the first time I have ever tried to compile a python program.我已经通读了 StackOverflow,但这也是我第一次尝试编译 python 程序。 So the problem is either something very unique and unusual, or I made a newb mistake.所以问题要么是非常独特和不寻常的,要么是我犯了一个新手错误。

I tried something similar with pyinstaller.我尝试了与 pyinstaller 类似的东西。 It builds without errors but crashes when executed with this error:它构建时没有错误,但在执行此错误时崩溃:

distutils.errors.DistutilsModuleError: invalid command 'build'
[42556] Failed to execute script setup

When I tried with nuitka I get this error:当我尝试使用 nuitka 时,出现此错误:

Davids-MBP:App degner$ python3 -m nuitka --follow-imports setup.py 
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/__init__.py:11: Cannot find 'setuptools.extern.six' in package 'setuptools' as absolute import (tried setuptools.extern.six).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/__init__.py:12: Cannot find 'setuptools.extern.six.moves' in package 'setuptools' as absolute import (tried setuptools.extern.six.moves).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/command/easy_install.py:46: Cannot find 'setuptools.extern.six.moves' in package 'setuptools.command' as absolute import (tried setuptools.extern.six.moves).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/command/easy_install.py:46: Cannot find 'setuptools.extern.six' in package 'setuptools.command' as absolute import (tried setuptools.extern.six).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/wheel.py:12: Cannot find 'setuptools.extern.packaging.utils' in package 'setuptools' as absolute import (tried setuptools.extern.packaging.utils).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/wheel.py:12: Cannot find 'setuptools.extern.packaging' in package 'setuptools' as absolute import (tried setuptools.extern.packaging).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/pep425tags.py:152: Cannot find '_manylinux' in package 'setuptools' as absolute import (tried _manylinux).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/ssl_support.py:45: Cannot find 'backports.ssl_match_hostname' in package 'setuptools' as absolute import (tried backports.ssl_match_hostname).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/sandbox.py:18: Cannot find 'org.python.modules.posix.PosixModule' in package 'setuptools' as absolute import (tried org.python.modules.posix.PosixModule).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/sandbox.py:18: Cannot find 'org.python.modules.posix' in package 'setuptools' as absolute import (tried org.python.modules.posix).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/sandbox.py:18: Cannot find 'org.python.modules' in package 'setuptools' as absolute import (tried org.python.modules).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/sandbox.py:18: Cannot find 'org.python' in package 'setuptools' as absolute import (tried org.python).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/sandbox.py:18: Cannot find 'org' in package 'setuptools' as absolute import (tried org).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/config.py:10: Cannot find 'setuptools.extern.packaging.version' in package 'setuptools' as absolute import (tried setuptools.extern.packaging.version).
Nuitka:WARNING:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/dist.py:31: Cannot find 'setuptools.extern.packaging.specifiers' in package 'setuptools' as absolute import (tried setuptools.extern.packaging.specifiers).
In file included from setup.build/CompiledCodeHelpers.c:1983:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nuitka/build/static_src/HelpersAttributes.c:553:6: error: conflicting types for 'SET_ATTRIBUTE'
bool SET_ATTRIBUTE(PyObject *target, PyObject *attr_name, PyObject *value) {
     ^
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nuitka/build/include/nuitka/helper/attributes.h:34:13: note: previous declaration is here
extern bool SET_ATTRIBUTE(PyObject *target, PyObject *attr_name, PyObject *value);
            ^
In file included from setup.build/CompiledCodeHelpers.c:1983:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nuitka/build/static_src/HelpersAttributes.c:594:6: error: conflicting types for 'SET_ATTRIBUTE_DICT_SLOT'
bool SET_ATTRIBUTE_DICT_SLOT(PyObject *target, PyObject *value) {
     ^
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nuitka/build/include/nuitka/helper/attributes.h:37:13: note: previous declaration is here
extern bool SET_ATTRIBUTE_DICT_SLOT(PyObject *target, PyObject *value);
            ^
In file included from setup.build/CompiledCodeHelpers.c:1983:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nuitka/build/static_src/HelpersAttributes.c:646:6: error: conflicting types for 'SET_ATTRIBUTE_CLASS_SLOT'
bool SET_ATTRIBUTE_CLASS_SLOT(PyObject *target, PyObject *value) {
     ^
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nuitka/build/include/nuitka/helper/attributes.h:40:13: note: previous declaration is here
extern bool SET_ATTRIBUTE_CLASS_SLOT(PyObject *target, PyObject *value);
            ^
3 errors generated.
scons: *** [setup.build/CompiledCodeHelpers.o] Error 1

There was a problem in py2app that made it incompatible with the six module. py2app 中存在一个问题,使其与六个模块不兼容。

Now it is fixed.现在它是固定的。

https://bitbucket.org/ronaldoussoren/py2app/issues/250/app-crashes-on-launch-when-compiled-with https://bitbucket.org/ronaldoussoren/py2app/issues/250/app-crashes-on-launch-when-compiled-with

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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