Using PIL with py2exe

J

John Carter

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
(e-mail address removed)
 
D

david.g.morgenthaler

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
(e-mail address removed)

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
 
M

Miki Tebeka

Hello David,
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
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 <[email protected]>"
# $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.filterwarnings("ignore")

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 McIdasImagePlugin
import MicImagePlugin
import MpegImagePlugin
import MspImagePlugin
import PalmImagePlugin
import PcdImagePlugin
import PcxImagePlugin
import PdfImagePlugin
import PixarImagePlugin
import PngImagePlugin
import PpmImagePlugin
import PsdImagePlugin
import SgiImagePlugin
import SunImagePlugin
import TgaImagePlugin
import TiffImagePlugin
import WmfImagePlugin
import XVThumbImagePlugin
import XbmImagePlugin
import XpmImagePlugin
--- pil2exe.py ---

Use at your own risk :)

HTH.
Miki
 
J

Justin Shaw

John Carter said:
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
(e-mail address removed)

Just import all of the plugins. I have this in a file called "plugins.py":


import JpegImagePlugin
import TgaImagePlugin
import PngImagePlugin
import GifImagePlugin
import PcxImagePlugin
import PpmImagePlugin
import BmpImagePlugin
import FliImagePlugin
import EpsImagePlugin
import DcxImagePlugin
import FpxImagePlugin
import ArgImagePlugin
import CurImagePlugin
import GbrImagePlugin
import IcoImagePlugin
import ImImagePlugin
import ImtImagePlugin
import IptcImagePlugin
import McIdasImagePlugin
import MicImagePlugin
import MspImagePlugin
import PcdImagePlugin
import PdfImagePlugin
import PixarImagePlugin
import PsdImagePlugin
import SgiImagePlugin
import SunImagePlugin
import TgaImagePlugin
import TiffImagePlugin
import WmfImagePlugin
import XVThumbImagePlugin
import XbmImagePlugin
import XpmImagePlugin
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,477
Latest member
ColumbusMa

Latest Threads

Top