pyinstaller and logging

Vinay Sajip vinay_sajip at yahoo.co.uk
Wed May 6 12:14:41 EDT 2009


On May 6, 2:41 pm, Mike <tornadoma... at gmx.net> wrote:
> Pyinstaller seems to have a problem withlogging...
>
>  I installed pyinstaller 1.3 - using it together with Python 2.6. I
> used pyinstaller for a small project, the created .exe worked fine.
> After some additional changes to my project I got strange run time
> errors when running the .exe (but no problems when running the .py
> file directly with the python interpreter). I stripped down my program
> and tracked the problem down to the first log message being written.
>
> So this is a stripped down version of the python script:
>
> importlogginglogging.basicConfig(level=logging.INFO,
>                     format='%(asctime)-15s %(levelname)-8s %(message)
> s',
>                     datefmt='%Y-%m-%d %H:%M:%S',
>                     filename="test1.log",
>                     filemode='w')
> print "written via print"logging.info("written vialogging")
>
> when I start this from the python shell I am getting
>            IDLE 2.6.2      ==== No Subprocess ====
>            >>>
>            written via print
>            >>>
> and test1.log contains
>            2009-05-05 19:39:52 INFO     written vialogging
> as expected.
>
> When I start test1.exe I am getting
>
> written via print
> Traceback (most recent call last):
>   File "<string>", line 8, in <module>
>   File "c:\dokumente und einstellungen\dieter\eigene dateien\collector
> \v0r0m2\buildtest1\out1.pyz/logging", line 1451, in info
>   File "c:\dokumente und einstellungen\dieter\eigene dateien\collector
> \v0r0m2\buildtest1\out1.pyz/logging", line 1030, in info
>   File "c:\dokumente und einstellungen\dieter\eigene dateien\collector
> \v0r0m2\buildtest1\out1.pyz/logging", line 1142, in _log
>   File "c:\dokumente und einstellungen\dieter\eigene dateien\collector
> \v0r0m2\buildtest1\out1.pyz/logging", line 1117, in makeRecord
>   File "c:\dokumente und einstellungen\dieter\eigene dateien\collector
> \v0r0m2\buildtest1\out1.pyz/logging", line 272, in __init__
>   File "C:\Programme\pyinstaller-1.3\iu.py", line 312, in importHook
>     mod = _self_doimport(nm, ctx, fqname)
>   File "C:\Programme\pyinstaller-1.3\iu.py", line 398, in doimport
>     exec co in mod.__dict__
>   File "c:\dokumente und einstellungen\dieter\eigene dateien\collector
> \v0r0m2\buildtest1\out1.pyz/multiprocessing", line 83, in <module>
>   File "C:\Programme\pyinstaller-1.3\iu.py", line 312, in importHook
>     mod = _self_doimport(nm, ctx, fqname)
>   File "C:\Programme\pyinstaller-1.3\iu.py", line 382, in doimport
>     mod = director.getmod(nm)
>   File "C:\Programme\pyinstaller-1.3\iu.py", line 215, in getmod
>     mod = owner.getmod(nm)
>   File "C:\Programme\pyinstaller-1.3\iu.py", line 77, in getmod
>     mod = imp.load_module(nm, fp, attempt, (ext, mode, typ))
> TypeError: importHook() takes at most 5 arguments (6 given)
>
> What am I doing wrong?

Apparently, PyInstaller only supports versions of Python between 1.5
and 2.4:

http://www.pyinstaller.org/#Requirements

So, you are using it in an unsupported environment. I see you've cross-
posted this to the PyInstaller mailing list:

http://groups.google.com/group/PyInstaller

I hope someone on that list can help. An additional bit of information
from your traceback is that line 272 in 2.6's logging/__init__.py is
one that says "from multiprocessing import current_process". As this
line is only executed if logging.logMultiProcessing is set, you may be
able to work around by setting logging.logMultiProcessing to False in
your app initialisation. Of course, this might just result in a
failure somewhere else...

Regards,

Vinay Sajip





More information about the Python-list mailing list