[reportlab-users] RE: "Bad file descriptor" after py2exe or Installer
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.
> -----Original Message-----
> From: firstname.lastname@example.org
> [mailto:email@example.com]On Behalf Of Luc Saffre
> Sent: 11 December 2003 18:07
> Cc: Installer@mi5t.com; firstname.lastname@example.org;
> Subject: [reportlab-users] "Bad file descriptor" after py2exe or
> 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
> But if I freeze it and invoke the `test.exe`, I get a strange
> c:\test\dist> test
> 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
> 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
> If I remove the following lines (41-46) of PIL/Image.py::
> # 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:
> then the problem disappears, and both script and executable work for
> If somebody sees an explanation, please let me know!
> Luc Saffre
> reportlab-users mailing list