在通过py2app之后,我无法让SQLAlchemy与我编译的应用程序一起工作。我已经用py2exe在Windows中成功地做到了这一点。以下是我的设置文件:
APP = ['Blah.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True,
'includes': ['sip',
'PyQt4._qt',
'sqlalchemy.dialects.mysql',
'MySQLdb',
"gzip"]
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)这看起来是正确的方法,因为我见过人们在sqlite中使用它,但是在编译之后尝试运行应用程序时,我仍然收到这个错误:
sqlalchemy.exc.ArgumentError: Could not determine dialect for 'mysql+mysqldb'
我最近一直在尝试使用PyInstaller,在几乎相同的地方被困住了,尽管出现了一个不同的错误,如下所示:
Traceback (most recent call last):
File "<string>", line 96, in <module>
File "/Users/tom/Downloads/pyinstaller-pyinstaller-2145d84/PyInstaller/loader/iu.py", line 386, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "/Users/tom/Downloads/pyinstaller-pyinstaller-2145d84/PyInstaller/loader/iu.py", line 480, in doimport
exec co in mod.__dict__
File "build/bdist.macosx-10.7-intel/egg/MySQLdb/__init__.py", line 19, in <module>
File "/Users/tom/Downloads/pyinstaller-pyinstaller-2145d84/PyInstaller/loader/iu.py", line 386, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "/Users/tom/Downloads/pyinstaller-pyinstaller-2145d84/PyInstaller/loader/iu.py", line 480, in doimport
exec co in mod.__dict__
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 4, in __bootstrap__
File "OSX_Installer/Jango/build/pyi.darwin/Jango/out00-PYZ.pyz/pkg_resources", line 882, in resource_filename
File "OSX_Installer/Jango/build/pyi.darwin/Jango/out00-PYZ.pyz/pkg_resources", line 1352, in get_resource_filename
File "OSX_Installer/Jango/build/pyi.darwin/Jango/out00-PYZ.pyz/pkg_resources", line 1363, in _extract_resource
KeyError: '_mysql/_mysql.so'发布于 2012-05-14 04:28:12
您可能还需要_mysql,它应该包含原生mysql绑定。此外,此绑定需要在目标系统上安装二进制mysql库。
如果您使用纯python mysql库,比如pymysql或MySQL Connector/Python (两者都是supported by sqlalchemy),那么您的应用程序可能会更容易移植。
https://stackoverflow.com/questions/10538032
复制相似问题