py2exe + sqlalchemy + sqlite problem

丶灬走出姿态 提交于 2019-12-03 02:49:35

问题


I am playing around with getting some basic stuff to work in Python before i go into full speed dev mode. Here are the specifics:

Python 2.5.4
PyQt4 4.4.3
SqlAlchemy 0.5.2
py2exe 0.6.9
setuptools 0.6c9
pysqlite 2.5.1

setup.py:

from distutils.core import setup
import py2exe

setup(windows=[{"script" : "main.py"}], options={"py2exe" : {"includes" : ["sip", "PyQt4.QtSql","sqlite3"],"packages":["sqlite3",]}})

py2exe appears to generate the .exe file correctly, but when i execute dist/main.exe i get this in the main.exe.log

Traceback (most recent call last):
  File "main.py", line 18, in <module>
  File "main.py", line 14, in main
  File "db\manager.pyc", line 12, in __init__
  File "sqlalchemy\engine\__init__.pyc", line 223, in create_engine
  File "sqlalchemy\engine\strategies.pyc", line 48, in create
  File "sqlalchemy\engine\url.pyc", line 91, in get_dialect
ImportError: No module named sqlite

I've been googling my heart out, but can't seem to find any solutions to this. If i can't get this to work now, my hopes of using Python for this project will be dashed and i will start over using Ruby... (not that there is anything wrong with Ruby, i just wanted to use this project as a good way to teach myself Python)


回答1:


you need to include the sqlalchemy.databases.sqlite package

setup(
  windows=[{"script" : "main.py"}],
  options={"py2exe" : {
    "includes": ["sip", "PyQt4.QtSql"],
    "packages": ["sqlalchemy.databases.sqlite"]
}})



回答2:


you need change to sqlalchemy.dialects.sqlite package

setup( windows=[{"script" : "main.py"}], options={"py2exe" : { "includes": ["sip", "PyQt4.QtSql"], "packages": ["sqlalchemy.dialects.sqlite"] }})



来源:https://stackoverflow.com/questions/582449/py2exe-sqlalchemy-sqlite-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!