pyinstaller and logging

Discussion in 'Python' started by Mike, May 6, 2009.

  1. Mike

    Mike Guest

    Pyinstaller seems to have a problem with logging ...

    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:

    import logging
    logging.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 via logging")

    when I start this from the python shell I am getting
    IDLE 2.6.2 ==== No Subprocess ====and test1.log contains
    2009-05-05 19:39:52 INFO written via logging
    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?
     
    Mike, May 6, 2009
    #1
    1. Advertisements

  2. Mike

    Vinay Sajip Guest

    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
     
    Vinay Sajip, May 6, 2009
    #2
    1. Advertisements

  3. Mike

    Mike Guest

    Shame on me - I somehow skipped the requirement from pyinstaller just
    supporting python between 1.5 and 2.4 ... - thanks for your help - I
    was aware it is not supporting python 3.0 (I searched a tool
    creating .exes for Python 3.0 in the first place). I googled around
    and found some recommendations for pyinstaller, but with the
    restriction "it is just supporting the latest version of 2.x but not
    3.0 of python". I never double checked on the formal requirements on
    the pyinstaller site... .

    Your hint regarding logging.logMultiProcessing=False did not change
    the problem. As I do not want to switch to python 2.4 I will have to
    look for something else. I tried py2exe today, which seems to work
    fine for my project (and officially supports python 2.6 ;-) ) - it is
    able to create an exe file within a dist directory, but not a single
    executable like pyinstaller is doing it. But this is fine enough for
    me just now.
     
    Mike, May 6, 2009
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.