Problem with SQLObject

8 views
Skip to first unread message

Benjamin Wohlwend

unread,
Mar 27, 2009, 6:38:43 AM3/27/09
to PyInstaller
Hi,

I'm quite new to PyInstaller, I've used py2exe until it's non-handling
of PyQT plugins bothered me to much. Anyway, I''ve gone through the
manual, and PyInstaller generates an executable, but when I run the
executable, it crashes (traceback at end of the message). Apparently,
PyInstaller doesn't like SQLObject[1]. My program has only these two
dependencies outside of the Python standard lib. Am I doing something
wrong? PyInstaller version is a SVN checkout from this morning.

Regards,
Benjamin

[1] http://www.sqlobject.org/

-------------
Traceback:

Traceback (most recent call last):
File "<string>", line 5, in <module>
File "C:\Python25\pyinstaller\iu.py", line 427, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Python25\pyinstaller\iu.py", line 512, in doimport
exec co in mod.__dict__
File "C:\Documents and Settings\Benjamin\workspace\QueryBrowser\src
\build\pyi.win32\querybrowser\outPYZ1.pyz/server", line 5, in <module>
File "C:\Python25\pyinstaller\iu.py", line 427, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Python25\pyinstaller\iu.py", line 512, in doimport
exec co in mod.__dict__
File "C:\Documents and Settings\Benjamin\workspace\QueryBrowser\src
\build\pyi.win32\querybrowser\outPYZ1.pyz/sql.models", line 4, in
<module>
File "C:\Python25\pyinstaller\iu.py", line 427, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Python25\pyinstaller\iu.py", line 512, in doimport
exec co in mod.__dict__
File "C:\Documents and Settings\Benjamin\workspace\QueryBrowser\src
\build\pyi.win32\querybrowser\outPYZ1.pyz/sqlobject", line 5, in
<module>
File "C:\Python25\pyinstaller\iu.py", line 427, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Python25\pyinstaller\iu.py", line 512, in doimport
exec co in mod.__dict__
File "C:\Documents and Settings\Benjamin\workspace\QueryBrowser\src
\build\pyi.win32\querybrowser\outPYZ1.pyz/sqlobject.main", line 31, in
<module>
File "C:\Python25\pyinstaller\iu.py", line 427, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Python25\pyinstaller\iu.py", line 512, in doimport
exec co in mod.__dict__
File "C:\Documents and Settings\Benjamin\workspace\QueryBrowser\src
\build\pyi.win32\querybrowser\outPYZ1.pyz/sqlobject.sqlbuilder", line
82, in <module>
File "C:\Python25\pyinstaller\iu.py", line 427, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Python25\pyinstaller\iu.py", line 512, in doimport
exec co in mod.__dict__
File "C:\Documents and Settings\Benjamin\workspace\QueryBrowser\src
\build\pyi.win32\querybrowser\outPYZ1.pyz/sqlobject.converters", line
21, in <module>
File "C:\Python25\pyinstaller\iu.py", line 427, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Python25\pyinstaller\iu.py", line 512, in doimport
exec co in mod.__dict__
File "C:\Documents and Settings\Benjamin\workspace\QueryBrowser\src
\build\pyi.win32\querybrowser\outPYZ1.pyz/sqlobject.Sybase", line 1,
in <module>
File "C:\Python25\pyinstaller\iu.py", line 427, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Python25\pyinstaller\iu.py", line 512, in doimport
exec co in mod.__dict__
File "C:\Documents and Settings\Benjamin\workspace\QueryBrowser\src
\build\pyi.win32\querybrowser\outPYZ1.pyz/sqlobject.dbconnection",
line 17, in <module>
File "C:\Python25\pyinstaller\iu.py", line 427, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Python25\pyinstaller\iu.py", line 512, in doimport
exec co in mod.__dict__
File "C:\Documents and Settings\Benjamin\workspace\QueryBrowser\src
\build\pyi.win32\querybrowser\outPYZ1.pyz/sqlobject.joins", line 236,
in <module>
AttributeError: 'module' object has no attribute 'SQLExpression'

Giovanni Bajo

unread,
Mar 27, 2009, 8:08:49 AM3/27/09
to PyIns...@googlegroups.com
On 3/27/2009 11:38 AM, Benjamin Wohlwend wrote:
> Hi,
>
> I'm quite new to PyInstaller, I've used py2exe until it's non-handling
> of PyQT plugins bothered me to much.

Alas, PyInstaller's automatic support is still not 100% OK since the
PyQt official installer puts the plugins in a directory which I can't
find a way to detect. I'm going to put more efforts into this soon.

> Anyway, I''ve gone through the
> manual, and PyInstaller generates an executable, but when I run the
> executable, it crashes (traceback at end of the message). Apparently,
> PyInstaller doesn't like SQLObject[1]. My program has only these two
> dependencies outside of the Python standard lib. Am I doing something
> wrong? PyInstaller version is a SVN checkout from this morning.

Thanks for reporting this, it's another case-sensitiveness problem
("import Sybase" in sqlobject/converters.py line 21 confuses PyInstaller
so that it thinks it's referring to the "sqlobject/sybase" package).

I thought we had fixed all of them but we had not :)

The attached patch fixes this problem. I can't commit right now because
we're in the middle of migration of PyInstaller's website and SVN
server, so SVN is locked down for writing for the time being. I'll
commit it as soon as the migration is over.

Anyway, if you manually apply the patch, you should be able to get on
testing your program with PyInstaller.

Thanks again!
--
Giovanni Bajo
Develer S.r.l.
http://www.develer.com

case.patch

Benjamin Wohlwend

unread,
Mar 27, 2009, 8:30:28 AM3/27/09
to PyIns...@googlegroups.com
Hi Giovanni,

On Fri, Mar 27, 2009 at 1:08 PM, Giovanni Bajo <ra...@develer.com> wrote:
>
> The attached patch fixes this problem.

wow, that was fast! Thank you! The executable that PyInstaller
generates works now with your patch, except that, apparently, it
doesn't pick up the needed JPEG plugin from Qt/PyQt. I also tried the
workaround from [1]. Is there another way to tell PyInstaller that it
should include those plugins and where it can find them?

Regards,
Benjamin

[1] http://pyinstaller.python-hosting.com/wiki/PyQtPluginsWorkaround?version=2

Giovanni Bajo

unread,
Mar 27, 2009, 10:44:05 AM3/27/09
to PyIns...@googlegroups.com
On 3/27/2009 1:30 PM, Benjamin Wohlwend wrote:
> Hi Giovanni,
>
> On Fri, Mar 27, 2009 at 1:08 PM, Giovanni Bajo <ra...@develer.com> wrote:
>> The attached patch fixes this problem.
>
> wow, that was fast! Thank you! The executable that PyInstaller
> generates works now with your patch, except that, apparently, it
> doesn't pick up the needed JPEG plugin from Qt/PyQt. I also tried the
> workaround from [1]. Is there another way to tell PyInstaller that it
> should include those plugins and where it can find them?

As I said, the problem is that PyInstaller is unable to ask PyQt where
Qt's plugins have been installed.

But you can hack it around: edit hooks/hookutils.py. You'll find this
function in there:

def qt4_plugins_dir():
return exec_statement("from PyQt4.QtCore import QLibraryInfo; print
QLibraryInfo.location(QLibraryInfo.PluginsPath)")


Replace its content with:

return "c:\\your\\path\\to\\Qt\\plugins"

And run Build.py again. PyInstaller should then do its magic automatically.

I hope to have time to fix this in the following days.

Benjamin Wohlwend

unread,
Mar 27, 2009, 2:52:40 PM3/27/09
to PyIns...@googlegroups.com
Thanks again for your fast answer!

On Fri, Mar 27, 2009 at 3:44 PM, Giovanni Bajo <ra...@develer.com> wrote:
>
> As I said, the problem is that PyInstaller is unable to ask PyQt where
> Qt's plugins have been installed.
>
> But you can hack it around: edit hooks/hookutils.py. You'll find this
> function in there:
>
> def qt4_plugins_dir():
>     return exec_statement("from PyQt4.QtCore import QLibraryInfo; print
> QLibraryInfo.location(QLibraryInfo.PluginsPath)")
>
>
> Replace its content with:
>
>     return "c:\\your\\path\\to\\Qt\\plugins"
>
> And run Build.py again. PyInstaller should then do its magic automatically.
>

I did that, and the executable is indeed 4 MBytes larger than before
(but still more than 10 MByte smaller than a py2exe build of the same
application :) ). But the JPEG files are still not painted by Qt. I
don't get any error messages, just blank widgets where images should
be... anyway, I have enough other things to do before the application
is anywhere near a deployable state. Thanks for your help!

Regards,
Benjamin

samc

unread,
Mar 28, 2009, 11:49:32 PM3/28/09
to PyInstaller
Ran into this as well today and the patch worked for me as well.
Thanks!
> [case.patch1K ]Index: mf.py
> ===================================================================
> --- mf.py       (revision 646)
> +++ mf.py       (working copy)
> @@ -86,7 +86,7 @@
>          if getsuffixes is None:
>              getsuffixes = self._getsuffixes
>          possibles = [(nm, 0, None)]
> -        if self._isdir(nm):
> +        if self._isdir(nm) and self._caseok(nm):
>              possibles.insert(0, (os.path.join(nm, '__init__'), 1, nm))
>          py = pyc = None
>          for pth, ispkg, pkgpth in possibles:
> Index: iu.py
> ===================================================================
> --- iu.py       (revision 646)
> +++ iu.py       (working copy)
> @@ -90,7 +90,7 @@
>                 loadco=marshal.loads, newmod=imp.new_module):
>          pth =  _os_path_join(self.path, nm)
>          possibles = [(pth, 0, None)]
> -        if pathisdir(pth):
> +        if pathisdir(pth) and caseOk(pth):
>              possibles.insert(0, (_os_path_join(pth, '__init__'), 1, pth))
>          py = pyc = None
>          for pth, ispkg, pkgpth in possibles:

snafu

unread,
Mar 29, 2009, 4:50:14 PM3/29/09
to PyInstaller


On 27 Mrz., 16:44, Giovanni Bajo <ra...@develer.com> wrote:

> As I said, the problem is that PyInstaller is unable to ask PyQt where
> Qt's plugins have been installed.

Is there only a problem in getting the prefix? Then what about this?

import os
import sys
from PyQt4 import QtCore, QtGui

QtGui.QApplication(sys.argv)
prefix = str(QtCore.QCoreApplication.applicationDirPath())

print os.path.join(
prefix.replace('/', os.sep),
'Lib',
'site-packages',
'PyQt4',
'plugins')

But I don't know if the subpathes are always the same...

snafu

unread,
Mar 29, 2009, 5:16:26 PM3/29/09
to PyInstaller
And much better seems to be:

for path in QtCore.QCoreApplication.libraryPaths():
print path
Reply all
Reply to author
Forward
0 new messages