[reportlab-users] RE: "Bad file descriptor" after py2exe or Installer

Michael Porter reportlab-users@reportlab.com
Fri, 12 Dec 2003 10:25:41 -0000


I had a similar problem to this when using cx_Freeze to freeze one of my
apps. This only occurred if I created a Windows GUI app (rather than a
console version) and seemed to be due to the lack of a proper stdout in this
situation. Not sure if this is related but in this case the error happened
when sys.stdout.flush() was being called.

Mike.


> -----Original Message-----
> From: reportlab-users-admin@reportlab.com
> [mailto:reportlab-users-admin@reportlab.com]On Behalf Of Luc Saffre
> Sent: 11 December 2003 18:07
> Cc: Installer@mi5t.com; theller@python.net;
> reportlab-users@reportlab.com
> Subject: [reportlab-users] "Bad file descriptor" after py2exe or
> Installer
>
>
> Hello,
>
> I had a strange problem when freezing (using either py2exe or McMillan
> installer) a script that imports reportlab (which imports PIL (which
> imports FixTk))).
>
> - Python 2.3.3c (also with Python 2.3)
> - PIL 1.1.4
> - Installer or py2exe : latest versions.
>
> Here is how I can reproduce it on a Win2000 and on a Win XP machine. I
> also found a hack that works for me, but have no idea why all
> this happens.
>
> The following script `test.py` runs without problem when interpreted:
>
>    print "before"
>    from PIL import Image
>    print "after"
>
> Output as expected:
>
>    c:\test>python test.py
>    before
>    after
>    c:\test>
>
> But if I freeze it and invoke the `test.exe`, I get a strange
> behaviour::
>
>    c:\test\dist> test
>    before
>    c:\test\dist>
>
> The second print just does not happen. And if I redirect stderr to a
> file, I see a bit more::
>
>    c:\test\dist> test 2> tmp.txt
>    before
>    c:\test\dist> type tmp.txt
>    Traceback (most recent call last):
>      File "test.py", line 3, in ?
>        print "after"
>    IOError: [Errno 9] Bad file descriptor
>    c:\test\dist>
>
> Workaround:
> If I remove the following lines (41-46) of PIL/Image.py::
>
> 	try:
> 		 # give Tk a chance to set up the environment, in case we're
> 		 # using an _imaging module linked against libtcl/libtk
> 		 import FixTk
> 	except ImportError:
> 		 pass
>
> then the problem disappears, and both script and executable work for
> me...
>
> If somebody sees an explanation, please let me know!
>
> Luc Saffre
>
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users@reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users