"Bad file descriptor" after py2exe or Installer
luc.saffre at gmx.net
Thu Dec 11 19:07:22 CET 2003
I had a strange problem when freezing (using either py2exe or McMillan
installer) a script that imports reportlab (which imports PIL (which
- 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:
from PIL import Image
Output as expected:
But if I freeze it and invoke the `test.exe`, I get a strange
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 ?
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
then the problem disappears, and both script and executable work for
If somebody sees an explanation, please let me know!
More information about the Python-list