问题
I have built Python's PIL library from source (due to an error in the version installed from the installer executable) and can create Image() objects from jpg files on the build computer, however when I package this Python application using PyInstaller, the application is unable to open JPEG images. Have I not built PIL correctly, as described at PIL encoder jpeg not available, or is something else wrong?
Update: The error message is "IOError: encoder jpeg not available".
Edit: The problem with the version installed from the installer executable (for both versions 1.1.7 and 1.1.6, if not earlier ones, too) is that it links against the VC90.DebugCRT library/assembly, which I don't is meant to be distributed and which PyInstaller could not find on my system (though a version was there).
回答1:
You need to include the jpeg encoder/decoder dll with your installation, otherwise it won't work on systems that doesn't already have it.
Haven't tried this myself, but you might also be able to do this by static linking instead by running the configure script with --enable-static.
回答2:
You have 2 choices:
use PIL's prebuilt binaries from http://www.pythonware.com/products/pil/
build from source (Note you have to setup JPEG library before get JPEG support, it's not easy on windows)
References ( not necessary for solving your problem ):
- "Prerequisites" of Pillow (a fork for PIL): https://pypi.python.org/pypi/Pillow/1.7.8#build-instructions-all-platforms
- see "Attention" of oscar: http://django-oscar.readthedocs.org/en/latest/internals/getting_started.html
Please ensure that pillow, a fork of the the Python Imaging Library (PIL), gets installed with JPEG support. Supported formats are printed when pillow is first installed. Instructions on how to get JPEG support are highly platform specific, but guides for PIL should work for pillow as well. Generally speaking, you need to ensure that libjpeg-dev is installed and found during installation.
来源:https://stackoverflow.com/questions/10453858/pil-and-jpeg-library-on-windows