20

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)

2 Answers 2

31

you need to include the sqlalchemy.databases.sqlite package

setup(
  windows=[{"script" : "main.py"}],
  options={"py2exe" : {
    "includes": ["sip", "PyQt4.QtSql"],
    "packages": ["sqlalchemy.databases.sqlite"]
}})
4
  • 1
    I would give you +100 if i could :) Thanks Commented Feb 24, 2009 at 16:57
  • 19
    For those arriving at this question years later: sqlalchemy no longer has a package with this name; instead, it seems to be sqlalchemy.dialects.sqlite. Commented Nov 12, 2010 at 16:22
  • 1
    In addiction to @Brandon's tip, for those using Firebird I found this option working: "packages": ["sqlalchemy.dialects.firebird", "kinterbasdb"]
    – bluish
    Commented Jan 10, 2011 at 10:47
  • 1
    For those using MySQL, you need to have "ascii": 0 and "packages": ["sqlalchemy.dialects.mysql","MySQLdb"] in your py2exe dictionary. For python2.7 and sqlalchemy .7 Commented Feb 1, 2012 at 16:07
5

you need change to sqlalchemy.dialects.sqlite package

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.