While Upgrading Python Imaging Library (pil), It Tells Me "jpeg Support Not Available"
Solution 1:
PIL
is essentially dead, the fork Pillow
is really what you should be using. You need to import it via
fromPILimportImage, ...
It maintains all of the functionality of PIL
, and adds a lot more, including Python 3 compatibility. Additionally, it's under active development, unlike PIL
, so any bugs you find actually have a chance of getting fixed - same with feature requests.
You can install it (after uninstalling PIL
) by running
pip install Pillow
I believe there's a package for Ubuntu, but my VM is giving me headaches at the moment and I can't check...
Solution 2:
According to this question at AskUbuntu:
It turns out that the APT installations put the libraries under /usr/lib/x86_64-linux-gnu and PIL will search for them in /usr/lib/. So you have to create symlinks for PIL to see them.
In other words, PIL apparently doesn't understand modern Ubuntu, or in fact most 64-bit linuxes.
What you probably want to do is:
- Switch to Pillow as MattDMo suggests,
- Use an Ubuntu package for PIL (
python-imaging
) instead of trying to install viapip
, or - Do both—use an Ubuntu package for Pillow, if there is one.
Checking on packages.ubuntu.com, the python-imaging
package is in fact Pillow 2.0.0 on Saucy (13.10). In fact, it's Pillow on anything Raring or later; it's only people still using 12.x or earlier versions who are stuck with PIL
. So, if you just do this:
$ sudo pip uninstall PIL
$ sudo apt-get install python-imaging
… that will get you Pillow, and pull in any dependencies it needs, all in one step.
If you don't want to do any of those, you should first reconsider that decision because it's probably a mistake, and then look at the workarounds suggested on that answer. In particular, symlinking the libs you installed into your /usr/lib directory is probably what you need. So, for example:
$ sudo pip uninstall PIL$ sudo apt-get install libjpeg-dev$ sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/libjpeg.so$ # repeat for the various other libraries, but JPEG is the one you asked about$ sudo pip install PIL
Alternatively, you could patch PIL itself, as some of the answers on the linked question show. In particular, add these two lines:
add_directory(library_dirs, "/usr/lib/x86_64-linux-gnu")
add_directory(library_dirs, "/lib/x86_64-linux-gnu")
… after the lines that add /usr/local/lib
and /usr/lib
.
However, if you're going to use a patched PIL, why not use Pillow, which has already solved this problem and many others?
Solution 3:
Additional notes for Mac OS X
On Mac OS X you will usually install additional software such as libjpeg or freetype with the "fink" tool, and then it ends up in "/sw". If you have installed the libraries elsewhere, you may have to tweak the "setup.py" file before building.
Additional notes for Windows
On Windows, you need to tweak the ROOT settings in the "setup.py" file, to make it find the external libraries. See comments in the file for details.
Make sure to build PIL and the external libraries with the same runtime linking options as was used for the Python interpreter (usually /MD, under Visual Studio).
Note that most Python distributions for Windows include libraries compiled for Microsoft Visual Studio. You can get the free Express edition of Visual Studio from:
http://www.microsoft.com/Express/
To build extensions using other tool chains, see the "Using non-Microsoft compilers on Windows" section in the distutils handbook:
http://www.python.org/doc/current/inst/non-ms-compilers.html
For additional information on how to build extensions using the popular MinGW compiler, see:
http://mingw.org (compiler)
http://sebsauvage.net/python/mingw.html (build instructions)
http://sourceforge.net/projects/gnuwin32 (prebuilt libraries)
Post a Comment for "While Upgrading Python Imaging Library (pil), It Tells Me "jpeg Support Not Available""