简体   繁体   English

py2app无法与MySQLdb一起使用

[英]py2app not working with MySQLdb

I am building an application which uses MySQLdb, whihc appears to build correctly, but when running this on another Mac it quits unexpectedly. 我正在构建使用MySQLdb的应用程序,虽然看起来可以正确构建,但是在另一台Mac上运行时却意外退出。 Is there any required steps to get MySQLdb included correctly with py2app? 是否有任何必要的步骤来使py2app正确包含MySQLdb? Here is my setup.py: 这是我的setup.py:

from setuptools import setup

APP = ['myApplication.py']
DATA_FILES = []
OPTIONS = {
                   'iconfile':'myIcon.icns',
                   'plist': {'CFBundleShortVersionString':'1.0',
                             'NSHumanReadableCopyright': u"Copyright © 2016, All Rights Reserved"}}

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

I have previously built this successfully using this exact setup and the exact same myApplication.py, which does run on other Macs, so the only thing which has changed is the version numbers, which are: 我以前已经使用此确切的设置和完全相同的myApplication.py(在其他Mac上运行)成功构建了此文件,因此唯一改变的是版本号,它们是:

Python: 2.7.11
MySQL-Python: 1.2.5
mysql-connector-python: 2.0.4
mysqlclient: 1.3.7
py2app: 0.9
setuptools: 20.3

Is there anything I can try to fix? 有什么我可以尝试修复的吗?

UPDATE: I just tried adding into the setup: 更新:我只是尝试添加到安装程序中:

PACKAGES = ['MySQLdb']
INCLUDES = ['MySQLdb']
OPTIONS = {'argv_emulation': True,
          'packages': PACKAGES,
          'includes': INCLUDES,
          } 

But I still get the quit unexpedidly, this is the start of the console crash log: 但是我仍然出人意料地退出,这是控制台崩溃日志的开始:

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libmysqlclient.18.dylib             0x000000010baf5e18 mysql_server_init + 132
1   _mysql.so                           0x00000001095b0fc1 0x1095ad000 + 16321
2   org.python.python                   0x00000001022c410c PyEval_EvalFrameEx + 40108
3   org.python.python                   0x00000001022c4ff3 PyEval_EvalCodeEx + 2131

Any other ideas I could try please? 还有其他我可以尝试的想法吗?

UPDATE: I am connecting to a MySQL Server version 5.6, do I need to update this? 更新:我正在连接到MySQL Server 5.6版,我需要更新它吗?

EDIT: Ups, sorry. 编辑:Ups,对不起。 My first answer was for py2exe. 我的第一个答案是py2exe。 I don't know if py2app creates a log on execution. 我不知道py2app是否创建执行日志。 In any case try the same approach suggested earlier: 无论如何,请尝试使用先前建议的相同方法:

    PACKAGES = ['MySQLdb']
    INCLUDES = ['MySQLdb']
    OPTIONS = {'argv_emulation': True,
              'packages': PACKAGES,
              'includes': INCLUDES,
              }  

ORIGINAL POST (I'll leave it just in case): The .exe file in the build should give you a log with more specific information about what failed. 原始帖子(以防万一):构建中的.exe文件应为您提供日志,其中包含有关失败原因的更具体信息。 In any case you might want to try including "MySQL" package directly in the setup: 无论如何,您都可以尝试直接在设置中包括“ MySQL”软件包:

    # setup.py
    from distutils.core import setup
    import py2exe

    includes = ["_mysql","MySQLdb","_mysql_exceptions",]

    options = {"py2exe": { # create a compressed zip archive
                          "compressed": 1,
                          "optimize": 2,
                          "includes": includes,
                              }}
    setup(
        options = options,
        console=['hamtainfo.py'],

        )

This code came directly from py2exe Mailing List 该代码直接来自py2exe 邮件列表

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

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