📜 ⬆️ ⬇️

Installing Python Image Library (PIL) on x64 systems using CentOS as an example

When developers require many different versions of python and django on the same host,
virtualenv ...

But after this, the additional modules for each python must be manually installed via pip

And here there are nuances. For example with the library PIL
')
It is perfectly installed, but when you try to work with it, it produces such magnificent error messages.

decoder jpeg not available

The problem is that when building a PIL, the library cannot work with jpeg, zlib, tiff, freetype, because in our case they are located in / usr / lib64, and it is written in PIL to search only in / usr / local / lib


Here is a diff that solves this problem:

 *** setup.py.orig 2012-12-01 16:11:49.000000000 +0400 --- setup.py 2012-12-01 16:12:15.000000000 +0400 *************** *** 147,152 **** --- 147,154 ---- add_directory(library_dirs, "/opt/local/lib") add_directory(include_dirs, "/opt/local/include") + + add_directory(library_dirs, "/usr/lib64") + add_directory(library_dirs, "/usr/lib") add_directory(library_dirs, "/usr/local/lib") # FIXME: check /opt/stuff directories here? 


And finally, an installation example for CentOS:
This implies that the required version of python and python-devel is already installed in the required
virtual environment.

 yum install libjpeg libjpeg-devel zlib zlib-devel libtiff libtiff-devel freetype freetype-devel wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz tar -zxvf Imaging-1.1.7.tar.gz cd Imaging-1.1.7 


Now patch setup.py and continue in the required virtual environment:

 python setup.py build --force python setup.py install 

Source: https://habr.com/ru/post/161517/


All Articles