Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
27
rated 0 times [  27] [ 0]  / answers: 1 / hits: 216053  / 2 Years ago, thu, may 5, 2022, 11:38:33

How do I install the python imaging library (PIL) on Ubuntu?



I tried doing



sudo apt-get install python-imaging


but now when i run
python selftest.py
(a script I got from somewhere on the http://pythonware.com/products/pil/ website)
I get (among other warning messages):



...
*** JPEG support not installed
*** ZLIB (PNG/ZIP) support not installed
...
*** 1 tests of 57 failed.


Have I somehow messed up the PIL -- how do I fix that?



Is maybe the PIL just fine, but that "selftest.py" is not really the right program for checking to see if PIL is installed properly -- how else can I tell if PIL is installed properly or not?



(I'm using Ubuntu 12.04 LTS "Precise Pangolin").



(What I'm ultimately trying to do is to add a 2D barcode generator to some python code,
and all the 2D barcode generators I could find that were written in python all seemed to use the PIL).


More From » python

 Answers
3

Something similar happened to me,
I solved this way



sudo apt-get install libjpeg libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev


And try there installing via pip install PIL.



More on what pip is can be found here. In short is a convenient (and becoming a standard) way of installing python libraries.



if it continues to fail, it can be due to PIL searching those libraries in a different path.




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.




Try to see if libjpeg and libz libs exist in /usr/lib/x86_64-linux-gnu and make a symlink this way



sudo ln -s /lib/x86_64-linux-gnu/libz.so.1 /lib/
sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so.6 /usr/lib/
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so.62 /usr/lib/





Source: http://jj.isgeek.net/2011/09/install-pil-with-jpeg-support-on-ubuntu-oneiric-64bits/


[#37255] Saturday, May 7, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
olltea

Total Points: 238
Total Questions: 115
Total Answers: 107

Location: Moldova
Member since Tue, Feb 7, 2023
1 Year ago
;