Using PIL with py2exe

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Carter

    Using PIL with py2exe

    Does anyone know how to embed PIL into a py2exe program.

    As far as I can tell PIL is not finding its plugins for Image I/O,
    they are imported dynamically as required. So I cant load or save
    pictures

    I tried making a copy of the plugin files to the application
    directory, but I've had no luck in making the code see the files
    I'd be grateful for any suggestion.

    Please e-mail me, as well as posting a reply.

    John Carter
    jnc@ecs.soton.a c.uk
  • david.g.morgenthaler@comcast.net

    #2
    Re: Using PIL with py2exe

    On Wed, 10 Dec 2003 16:04:41 +0000, John Carter <jnc@ecs.soton. ac.uk>
    wrote:
    [color=blue]
    >Does anyone know how to embed PIL into a py2exe program.
    >
    >As far as I can tell PIL is not finding its plugins for Image I/O,
    >they are imported dynamically as required. So I cant load or save
    >pictures
    >
    >I tried making a copy of the plugin files to the application
    >directory, but I've had no luck in making the code see the files
    >I'd be grateful for any suggestion.
    >
    >Please e-mail me, as well as posting a reply.
    >
    >John Carter
    >jnc@ecs.soton. ac.uk[/color]

    PIL imports the drivers dynamically, so py2exe doesn't find them.
    Including these lines should solve your problem.

    ## Static imports from PIL for py2exe
    from PIL import GifImagePlugin
    from PIL import JpegImagePlugin

    Comment

    • Miki Tebeka

      #3
      Re: Using PIL with py2exe

      Hello David,
      [color=blue][color=green]
      > >Does anyone know how to embed PIL into a py2exe program.
      > >
      > >As far as I can tell PIL is not finding its plugins for Image I/O,
      > >they are imported dynamically as required. So I cant load or save
      > >pictures[/color]
      > PIL imports the drivers dynamically, so py2exe doesn't find them.
      > Including these lines should solve your problem.
      >
      > ## Static imports from PIL for py2exe
      > from PIL import GifImagePlugin
      > from PIL import JpegImagePlugin[/color]
      I had the same problem, created a script call pil2exe which I import in my modules.

      --- pil2exe.py ---
      '''Fix allowing PIL to work under py2exe'''

      __author__ = "Miki Tebeka <mikit@zoran.co .il>"
      # $Id: pil2exe.py,v 1.2 2003/10/20 11:35:38 mikit Exp $

      #FIXME:
      # Hand pick only the modules you need (currently all *Plugin.py from PIL
      # directory are imported)

      #FIXME: Find who's the criminal and why, currently disable warnings
      import warnings
      warnings.filter warnings("ignor e")

      import ArgImagePlugin
      import BmpImagePlugin
      import CurImagePlugin
      import DcxImagePlugin
      import EpsImagePlugin
      import FliImagePlugin
      import FpxImagePlugin
      import GbrImagePlugin
      import GifImagePlugin
      import IcoImagePlugin
      import ImImagePlugin
      import ImtImagePlugin
      import IptcImagePlugin
      import JpegImagePlugin
      import McIdasImagePlug in
      import MicImagePlugin
      import MpegImagePlugin
      import MspImagePlugin
      import PalmImagePlugin
      import PcdImagePlugin
      import PcxImagePlugin
      import PdfImagePlugin
      import PixarImagePlugi n
      import PngImagePlugin
      import PpmImagePlugin
      import PsdImagePlugin
      import SgiImagePlugin
      import SunImagePlugin
      import TgaImagePlugin
      import TiffImagePlugin
      import WmfImagePlugin
      import XVThumbImagePlu gin
      import XbmImagePlugin
      import XpmImagePlugin
      --- pil2exe.py ---

      Use at your own risk :-)

      HTH.
      Miki

      Comment

      Working...