SQLAlchemy and py2exe problem

126 views
Skip to first unread message

Karlo Lozovina

unread,
Dec 18, 2006, 11:01:35 PM12/18/06
to sqlalchemy
Hi all,

I've posted this few minutes ago on c.l.python, but since I'm
desperate, I'll do it here to:

I'm working with SQLAlchemy 0.3.3, Python 2.5 and py2exe 0.6.5. This
simple scripts fails when I run test.exe:

*** test.py: ***
import sqlalchemy
print 'Test'
***

It works when interpreted by Python, but when running it from compiled
py2exe binary, it fails with this error:

Traceback (most recent call last):
File "main.py", line 1, in <module>
File "sqlalchemy\__init__.pyc", line 10, in <module>
File "sqlalchemy\orm\__init__.pyc", line 12, in <module>
File "sqlalchemy\orm\mapper.pyc", line 7, in <module>
File "sqlalchemy\logging.pyc", line 30, in <module>
ImportError: No module named logging

Ofcourse, library.zip (in the dist directory) contains 'sqlalchemy
\logging.pyc'. After I copy logging.pyc to library.zips' root, I get
this error:

Traceback (most recent call last):
File "main.py", line 1, in <module>
File "sqlalchemy\__init__.pyc", line 10, in <module>
File "sqlalchemy\orm\__init__.pyc", line 12, in <module>
File "sqlalchemy\orm\mapper.pyc", line 7, in <module>
File "sqlalchemy\logging.pyc", line 30, in <module>
File "sqlalchemy\logging.pyc", line 33, in <module>
AttributeError: 'module' object has no attribute 'getLogger'

I really don't know what to do next, so any kind of help is
appreciated. First of all, I'm wondering is this SQLAlchemys' problem,
or is py2exe guilty?

Thanks guys...

Michael Bayer

unread,
Dec 19, 2006, 10:20:57 AM12/19/06
to sqlalchemy
most likely this is an incompatibility with SA's usage of the name
"logging" as a module name, which is also a standard python module (you
might have the same issue with the "types" module). absolute module
imports by default are to become the standard in py2.6 and i believe
are supported in py2.5, which should eliminate this silly issue, but i
dont know much about py2exe.

so short answer, "theyre both guilty"...SA for expecting absolute
module behavior, py2exe for assuming relative.

show the py2exe folks the evil thing im doing in sqlalchemy.logging (im
importing the python's "logging" via __import__) and im sure theyll
shake their heads in disgust....if they cant offer a solution, and you
are truly "desperate", youll have to change the name "logging" (and
maybe "types" as well) throughout your SA dist.

ml

unread,
Dec 19, 2006, 12:04:14 PM12/19/06
to sqlal...@googlegroups.com
Hi!

I had similar problem with module "postgres". py2exe didn't automaticaly
include the module so I simply put "import
sqlalchemy.databases.postgres" into the main script. Perhaps you should
try something like this with the logging.

DS


Karlo Lozovina píše v Út 19. 12. 2006 v 04:01 +0000:

Oleg Deribas

unread,
Dec 24, 2006, 7:11:40 AM12/24/06
to sqlal...@googlegroups.com
Hello,

Karlo Lozovina said the following on 19.12.2006 6:01:

> I'm working with SQLAlchemy 0.3.3, Python 2.5 and py2exe 0.6.5. This
> simple scripts fails when I run test.exe:

> ImportError: No module named logging

Have you solved this problem? I want to try to use py2exe also.

--
Oleg

Reply all
Reply to author
Forward
0 new messages