我正在构建一个使用MySQLdb的应用程序,似乎可以正确构建,但是当在另一台Mac上运行时,它会意外退出。 是否有任何必要的步骤来使用py2app正确包含MySQLdb? 这是我的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'],
)
我之前已经使用这个确切的设置和完全相同的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
我有什么可以尝试解决的吗?
更新: 我刚刚尝试添加到设置中:
PACKAGES = ['MySQLdb']
INCLUDES = ['MySQLdb']
OPTIONS = {'argv_emulation': True,
'packages': PACKAGES,
'includes': INCLUDES,
}
但我仍然无法解决这个问题,这是控制台崩溃日志的开始:
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
我可以尝试其他任何想法吗?
更新: 我正在连接MySQL服务器版本5.6,我需要更新吗?
答案 0 :(得分:0)
PACKAGES = ['MySQLdb']
INCLUDES = ['MySQLdb']
OPTIONS = {'argv_emulation': True,
'packages': PACKAGES,
'includes': INCLUDES,
}
原始邮寄(我会留下以防万一): 构建中的.exe文件应该为您提供一个日志,其中包含有关失败的更多具体信息。在任何情况下,你可能想尝试包括" 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'],
)
此代码直接来自py2exe Mailing List