How can i add pillow to yocto image rocko branch? - python-imaging-library

We're working on an older yocto release, and I'm trying to add pillow to our image. Sadly it seems open-embedded lacks pillow recipe for rocko (branch), and the one found in meta-printing appears to be broken (it errors out when building). Can someone perhaps provide me with a working recipe, or other method to get pillow installed? Should be noted, we're on python 3.5.
Thanks in advance.

Related

How to install pre-built Pillow wheel with libraqm DLLs on Windows?

I tried using the pre-built wheels for Pillow and corresponding libraqm DLL from here:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow
But the following returns False:
from PIL import features
features.check('raqm')
Am I missing anything?
Context: I need libraqm with Pillow to work with complex fonts on images, as shown here.
For anyone who wants RAQM with PIL on Windows, just do pip install Pillow.
Then place the libraqm DLLs in some directory, and then append that directory to environment/shell variable PYTHONPATH. That's it.
Or you could place those DLLs along with your python.exe as commented by #cgohlke.
Just in-case someone wants to know, I'm currently on Python 3.7 (Windows 10) with Pillow 7.2.0 and libraqm-0.7.0.dll

Missing CGAL/hierarchy_simplify_point_set.h file in ubuntu install

I am trying to build some source code on ubuntu 16.04 where one of the classes relies hierarchy_simplify_point_set.h header file, which is part of CGAL's point set package. After following instruction on the installation page, I have installed libcgal-dev and libcgal-qt5-dev via apt-get. The package manager has installed libcgal-dev 4.7 which should include the point set library. However, the particular header file seems to be missing (it seems to have some files from the point set library and not others - I am looking in /usr/include/CGAL). Does anyone know what I am doing wrong?
ps: For good measure, I have already tried uninstalling and reinstalling both the packages, but no luck.
This header has been introduced in CGAL 4.8 while it seems you are using CGAL 4.7.
You can get the latest version of CGAL here. Since the latest versions can be used as a header-only library, simply extract the release archive somewhere and set CGAL_DIR to that location when calling cmake to configure your example and it should work directly.

How to add ldd utility to bitbake image

I need ldd utility in my final image of yocto. When I needed usbutils before, I went ahead and added the line in ../build/conf/local.conf file
CORE_IMAGE_EXTRA_INSTALL += "usbutils"
After searching around I came to see that ldd is part of the libc-bin package, atleast on my Ubuntu machine. But after reading this, I see that it is in eglibs recipe and not part of the standard package. Adding libc-bin similar to usbutils threw a Nothing RPROVIDES libc-bin error which is understandable.
What are the steps I take to get ldd onto my image if I need to add eglibs recipe. If not, is there another way I can do this.
Please bear with me, still a newbie with yocto and bitbake.
How to add "ldd" to your image depends on the used C library.
In case of glibc:
At least for the current "zeus" version the glibc recipes provide a separate ldd package, see: https://git.openembedded.org/openembedded-core/tree/meta/recipes-core/glibc/glibc-package.inc?h=zeus#n27
In case of musl:
At least for the current "zeus" version the musl package itself provides ldd, see: https://git.openembedded.org/openembedded-core/tree/meta/recipes-core/musl/musl_git.bb?h=zeus#n91
Adding packages to your image can be done in various ways but I would recommend to use
IMAGE_INSTALL_append. For more info in this topic please consult the YoctoProject manual: https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#usingpoky-extend-customimage.

enthought mahotas.imread cannot find freeimage

I'm new to python and it was recommended that I use Canopy. I'm trying to follow along with this tutorial, but I get stuck at the mahotas.imread line. I get an error saying that ends with this:
Full error was: mahotas.freeimage: could not find libFreeImage in any
of the following directories:
'/Users/RJD/Library/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/mahotas',
'/lib', '/usr/lib', '/usr/local/lib', '/opt/local/lib'
I've added the mahotas package via the package manager to no avail. Also tried the steps here, with no different result.
I am actually able to find 'freeimage.py' and 'freeimage.pyc' in '/Users/RJD/Library/Enthought/Canopy_32bit/User/lib/python2.7/site-packages/mahotas'. How do I go about telling Canopy that it is there?!
Any help would be very much appreciated.
Cheers,
R
Author of mahotas here:
Mahotas itself does not have the functionality to read in images. imread is just a wrapper around one of 3 backends:
mahotas-imread (i.e., https://pypi.python.org/pypi/imread)
FreeImage (this was the original version and if you have such an old version [0.7.1 is from Jan '12], it might still only support FreeImage)
matplotlib (which only supports PNG & JPEG)
Thus, you need to install one of the packages above.
To be clear, there is no "enthought mahotas". Mahotas is not in the Enthought package repository but in our "Community" (PyPi mirror) repo of 11,000 untested ("as is") packages, as you can see by the "PyPI" logo in the Package Manager (sorry, that's not at all obvious, we'll fix this!) We will be updating this repo later this year. The version of mahotas in that PyPI repo is 0.7.1, whereas the current version of mahotas on PyPI is 1.0.2. So that avenue is not useful for now.
When you say that you tried the steps in the cmu.edu document, was that after uninstalling the old PyPI version just mentioned and going through each step mentioned in that document?

Django OS X Wrong JPEG library version: library is 80, caller expects 62 sorl.thumbnail

Im using sorl.thumbnail for django locally on my mac and have been having trouble with PIL, but today i finally managed to get it installed - was some trouble with libjpeg.
I can now upload and use images - but I cant resize them using sorl.thumbnail.
When i try i get the following error:
Wrong JPEG library version: library is 80, caller expects 62
Does anyone know a good solution for this.
I dont know wether whatever sorl uses requires an earlier version of libjpeg or wether there is some ghost install of something still left behind from all of my tries with various methods.
I have :
PIL 1.1.7
libjpeg 8.
anyone know an approach?
For the benefit of the people from the future who are encountering this error and don't know why, I'd like to post my findings. I hope to give a general understanding of what's gone wrong since the exact commands to fix it may be different on your machine than on my OSX Lion install.
First, since it's easy to get lost in the potential solutions, it's important to understand that the error message is correct when it says Wrong JPEG library version: library is 80, caller expects 62 or some other combination of 62, 70, and 80. These numbers correspond to the different incompatible versions of libjpeg. There are two moving pieces here, the dynamically loaded jpeg library, and the PIL (or Pillow) install. What the error message is saying is that your PIL install was compiled with headers from libjpeg version 6.2, but when it goes to load up the actual shared library, it's being linked to version 8.0.
The fix is to download, build, and install the libjpeg version you want (any will do, though the later versions build easier on OSX Lion):
wget http://www.ijg.org/files/jpegsrc.v8d.tar.gz
tar xzf jpegsrc*
cd jpeg-*
./configure
make
sudo make install
This should drop 2 files of note in '/usr/local/'. Namely /usr/local/lib/libjpeg.8.dylib and /usr/local/include/jpeglib.h. Now we just have to get PIL (or Pillow) to use these two files at install time, and we're home free. I know there's a better way to do this, but the hack (as recommended by the PIL docs) is to edit the setup.py file of the PIL distribution before you install it. You may get away with just setting JPEG_ROOT = libinclude('/usr/local') near the top of setup.py, though further directory manipulation may be necessary elsewhere in the file.
As you fiddle with the paths, you have to make sure PIL does a full rebuild before you test out whether it linked up to the right library or not. I used a command like rm -rf build && python setup.py install to make sure the library was always freshly linked to the current path I was testing.
I'm sorry this is a rambling answer, but it was very disheartening to have tried every other copy & paste solution out there and have none of them work. Hopefully this answer keeps at least a few folks from wasting numerous hours in search of a simplistic solution.
Good Luck!
If you have macports installed, you should do a:
$ sudo port selfupdate
$ sudo port install py27-pil
It's easier than the easy_install method since macports install the right dependencies.
I had a slightly different problem than the OP, but I wanted to share my solution here to help someone in the future.
OS: OSX El Capitan
I installed libjpeg-turbo from the precompiled binaries on their website. However, I did not know that I already had a different version of libjpeg installed on my mac. I was building my c file like this gcc myfile.c -o myfile.out -L /opt/libjpeg-turbo/lib -ljpeg. This got the library from the correct location, but the the linker was getting the included header file jpeglib.h from the pre-installed location. I changed my build command to this: gcc myfile.c -o myfile.out -I/opt/libjpeg-turbo/include/ -L /opt/libjpeg-turbo/lib -ljpeg and it worked. No more library is 80, caller expects 62!
Like a previous answer, I had a slightly different problem than the OP, but I wanted to share my solution here to help someone in the future.
The only thing that worked for me was forcing pip to build pillow from source after installing the dev version of the needed libraries (my code was editing a jpg and adding a label using a custom font). This was on a ARM based embedded device running Ubuntu Linux using Python 3.7.3
apt-get install -y libjpeg-dev libfreetype6-dev
pip3 install pillow --global-option="build_ext" --global-option="--enable-jpeg" --global-option="--enable-freetype"