PIL: selftest fails, but package shows status is fine? - python

I have PIL installed with the required libraries (so I think). During installation it shows
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
--- LITTLECMS support available
However, when I run selftest.py, I get this:
*** PIL CORE support not installed
*** TKINTER support not installed
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
*** FREETYPE2 support not installed
*** LITTLECMS support not installed
i.e. it's not detecting PIL CORE, FREETYPE2 and LITTLECMS.
I installed the following packages on CentOS 6.0 using python 2.6.5
libjpeg libjpeg-devel zlib zlib-devel freetype freetype-devel lcms lcms-devel
PIL was installed with pip install PIL. However, the selftest was run from a source code from the offical PIL website.
Any ideas?

Try building the C extensions in-place in the source directory with setup.py build_ext -i before running selftest.py or Tests\run.py.

Related

Upgrading pillow from version 8.3.2-> 9.1.1

I am upgrading pillow from version 8.3.2 to 9.1.1.
A little confused by the release notes. version 9.0.0 and above are built against libjpeg-turbo.
Does it mean we must have libjpeg-turbo installed on our servers as well?
or is it fine to stick with libjpeg-dev package we have.
The binary wheels for Pillow are statically compiled against the basic format libraries, as evident from compiled for libjpeg-turbo 2.1.3 being present in the slimmest Python container:
~ $ docker run -it python:3.10-slim-bullseye bash
root#4fb371115880:/# pip install -q Pillow
root#4fb371115880:/# python -c 'from PIL.features import pilinfo; pilinfo()'
--------------------------------------------------------------------
Pillow 9.1.1
Python 3.10.5 (main, Jun 7 2022, 18:49:47) [GCC 10.2.1 20210110]
--------------------------------------------------------------------
Python modules loaded from /usr/local/lib/python3.10/site-packages/PIL
Binary modules loaded from /usr/local/lib/python3.10/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 9.1.1
*** TKINTER support not installed
--- FREETYPE2 support ok, loaded 2.12.1
--- LITTLECMS2 support ok, loaded 2.13.1
--- WEBP support ok, loaded 1.2.2
--- WEBP Transparency support ok
--- WEBPMUX support ok
--- WEBP Animation support ok
--- JPEG support ok, compiled for libjpeg-turbo 2.1.3
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.0
--- ZLIB (PNG/ZIP) support ok, loaded 1.2.11
--- LIBTIFF support ok, loaded 4.3.0
*** RAQM (Bidirectional Text) support not installed
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
In other words, no, you don't need to install libjpeg-turbo (or libjpeg, even) separately if you don't compile Pillow yourself.

OS X virtualenv Pillow and Jpeg support

I have Pillow working on my OS X Mavericks machine. But when I try to install it in a virtualenv, I can't seem to get JPEG support working.
Here's the summary output of pip install Pillow in the virtualenv:
--------------------------------------------------------------------
PIL SETUP SUMMARY
--------------------------------------------------------------------
version Pillow 2.5.3
platform darwin 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
--------------------------------------------------------------------
--- TKINTER support available
*** JPEG support not available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBTIFF support not available
*** FREETYPE2 support not available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available
--------------------------------------------------------------------
It seems I could try to edit setup.py to point to the relevant libs, but I'm new to virtualenv, and don't know where setup.py is.
EDIT:
Well, I solved it by linking from the virtualenv to the working Pillow library.
You should install libjpeg first, as the doc says:
http://pillow.readthedocs.org/en/latest/installation.html#external-libraries
libjpeg provides JPEG functionality.
Install libjpeg using homebrew: brew install libjpeg
So, my solution was to link to the working install of Pillow from the virtualenv.

Pillow recognizes JPEG encoder on install, but not use

I'm doing some work on a vagrant box running Ubuntu 13.04 and python 3.3. I've installed Pillow and libjpeg-dev (installing the latter first, as recommended), and when I install (or re-install Pillow, I see this:
--------------------------------------------------------------------
PIL SETUP SUMMARY
--------------------------------------------------------------------
version Pillow 2.3.0
platform linux 3.3.1 (default, Sep 25 2013, 19:29:01)
[GCC 4.7.3]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
Great! JPEG encoder recognized. Except, when I run Pillow's selftest.py script, it fails a bunch of tests and starts off with this:
--------------------------------------------------------------------
Pillow 2.3.0 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from /usr/local/lib/python3.3/dist-packages/PIL
Binary modules loaded from /usr/local/lib/python3.3/dist-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok
*** TKINTER support not installed
*** JPEG support not installed
--- ZLIB (PNG/ZIP) support ok
So now it's not recognizing the JPEG decoder. To make sure this isn't just a problem with selftest.py, I did my testing and sure enough I can make and manipulate .pngs but not .jpgs. I've searched around and tried some suggested solutions, including making a symbolic link to the jpg library, like so:
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
No dice. Anybody have an idea of something else I could try to get the jpeg decoder working? It really isn't practical for me to restrict the workflow entirely to .png.
And, this is why I need to wait 24 hours before posting questions. I needed to pay attention to the Pillow install path. It works if I create the symlink like so:
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/local/lib/
/usr/lib wasn't in the Pillow search path, but the above is.

Installing pillow on windows fails to find libjpeg

Sys: Windows 7 Prof;
Python v3.3
I've tried to use:
'easy_install Pillow'
'pip install use-wheel Pillow'
Download package manually and 'python setup.py install'
but all the time i cant install any extensions:
*** TKINTER support not available
(Tcl/Tk 8.5 libraries needed)
*** JPEG not support available
*** ZLIB (PNG/ZIP) support not available
*** TIFF G3/G4 (experimental) support not available
*** FREETYPE2 support not available
*** LITTLECMS support not available
*** WEBP support not available
I've manually installed libjpeg but still the results were the same. I've alsot tried to change JPEG_ROOT path to point it somehow to the correct dll but it did not work too.
Any idea how to solve this?
try python extension packages for windows:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
There are 32- and 64-bit Windows binaries you can simply install

Challenge installing psd-tools on fresh Mac

I've been using PSD-TOOLS to great effect on a 13" notebook for half a year now (Python 2.7.3). Just tried to do a fresh install on a Mac running 10.8.4.
I ran through the python setup at http://docs.python-guide.org/en/latest/starting/install/osx/ (Python version
Installed Pil using:
sudo pip install pil
All my Pil scripts work fine.
pip list
shows PIL (1.1.7) installed fine.
Then tried to install psd-tools using:
sudo pip install psd-tools
Appears to install fine but when I run my PSD scripts, get the following:
File "/Library/Python/2.7/site-packages/psd_tools/user_api/psd_image.py", line 91, in as_PIL
return self._psd._layer_as_PIL(self._index)
File "/Library/Python/2.7/site-packages/psd_tools/user_api/psd_image.py", line 243, in _layer_as_PIL
return pil_support.extract_layer_image(self.decoded_data, index)
File "/Library/Python/2.7/site-packages/psd_tools/user_api/pil_support.py", line 32, in extract_layer_image
decoded_data.header.depth, get_icc_profile(decoded_data))
File "/Library/Python/2.7/site-packages/psd_tools/user_api/pil_support.py", line 68, in _channels_data_to_PIL
raise Exception("This module requires PIL (or Pillow) installed.")
Exception: This module requires PIL (or Pillow) installed.
Anybody run into this issue?
I ran into this issue on OSX 10.9 with Python 2.7.5. (In a virtualenv)
I ended up going over https://pypi.python.org/pypi/Pillow/2.2.1 and installing some optional prerequisites for Pillow.
#I already had libjpeg but this is the line in their doc.
brew install libtiff libjpeg webp littlecms
#Then re-installed Pillow
pip install --force-reinstall --upgrade pillow
The result was the following features enabled
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- TIFF G3/G4 (experimental) support available
*** FREETYPE2 support not available
--- LITTLECMS support available
--- WEBP support available
--- WEBPMUX support available
And my small python test ran
from PIL import Image
from psd_tools import PSDImage
psd = PSDImage.load('test_data/1.psd')
merged_image = psd.as_PIL()
Not sure which of those requirements was responsible so if you are not interested in installing extra libraries you may have to do 1 at a time or dig into the source.

Categories

Resources