Can't install Pillow on Android
What did you do?
I'm running Python on Android (with Termux).
I'm trying to install Pillow by running pip install Pillow.
What did you expect to happen?
Install Pillow.
What actually happened?
Collecting Pillow
Using cached Pillow-3.2.0.zip
Installing collected packages: Pillow
Running setup.py install for Pillow ... error
Complete output from command /data/data/com.termux/files/usr/bin/python -u -c "import setuptools, tokenize;__file__='/data/data/com.termux/files/usr/tmp/pip-build-ufp_l0v2/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /data/data/com.termux/files/usr/tmp/pip-403p6uq1-record/install-record.txt --single-version-externally-managed --compile:
Exception installing mp_compile, proceeding without:This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770.
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-3.5
creating build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageGrab.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/TiffImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/MicImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/FitsStubImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ExifTags.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageChops.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/CurImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageEnhance.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/WebPImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/PngImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/DcxImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/TgaImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/PsdImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/JpegPresets.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/GimpPaletteFile.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/GbrImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/OleFileIO.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/PSDraw.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/_binary.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageSequence.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/DdsImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/McIdasImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/IptcImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageTransform.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/PdfImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/JpegImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/FontFile.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/Hdf5StubImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/PcxImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/WalImageFile.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageQt.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageFile.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/IcnsImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/BufrStubImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/EpsImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/TiffTags.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/BmpImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/MpoImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/GimpGradientFile.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/SgiImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageCms.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageDraw2.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageStat.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/SpiderImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageWin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/Jpeg2KImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/__init__.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImagePalette.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/FtexImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/Image.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/SunImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageFont.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageTk.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/TarIO.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageShow.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/PpmImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/XpmImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageColor.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/PyAccess.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/GifImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImagePath.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageFilter.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageMode.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/features.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/GdImageFile.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ContainerIO.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/MspImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/PalmImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageMath.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/FliImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/MpegImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/PcfFontFile.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/XbmImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageOps.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageDraw.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/PixarImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/BdfFontFile.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/FpxImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/IcoImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImtImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/PcdImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/PaletteFile.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/_util.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/ImageMorph.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/XVThumbImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/WmfImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
copying PIL/GribStubImagePlugin.py -> build/lib.linux-armv7l-3.5/PIL
running egg_info
writing dependency_links to Pillow.egg-info/dependency_links.txt
writing top-level names to Pillow.egg-info/top_level.txt
writing Pillow.egg-info/PKG-INFO
warning: manifest_maker: standard file '-c' not found
reading manifest file 'Pillow.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.sh'
no previously-included directories found matching 'docs/_static'
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.editorconfig'
warning: no previously-included files found matching '.landscape.yaml'
warning: no previously-included files found matching 'appveyor.yml'
warning: no previously-included files found matching 'build_children.sh'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files matching '.git*' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.so' found anywhere in distribution
writing manifest file 'Pillow.egg-info/SOURCES.txt'
copying PIL/OleFileIO-README.md -> build/lib.linux-armv7l-3.5/PIL
running build_ext
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/data/data/com.termux/files/usr/tmp/pip-build-ufp_l0v2/Pillow/setup.py", line 767, in <module>
zip_safe=not debug_build(), )
File "/data/data/com.termux/files/usr/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/data/data/com.termux/files/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/data/data/com.termux/files/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/data/data/com.termux/files/usr/lib/python3.5/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/data/data/com.termux/files/usr/lib/python3.5/distutils/command/install.py", line 539, in run
self.run_command('build')
File "/data/data/com.termux/files/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/data/data/com.termux/files/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/data/data/com.termux/files/usr/lib/python3.5/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/data/data/com.termux/files/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/data/data/com.termux/files/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/data/data/com.termux/files/usr/lib/python3.5/distutils/command/build_ext.py", line 338, in run
self.build_extensions()
File "/data/data/com.termux/files/usr/tmp/pip-build-ufp_l0v2/Pillow/setup.py", line 512, in build_extensions
' using --disable-%s, aborting' % (f, f))
ValueError: zlib is required unless explicitly disabled using --disable-zlib, aborting
----------------------------------------
Command "/data/data/com.termux/files/usr/bin/python -u -c "import setuptools, tokenize;__file__='/data/data/com.termux/files/usr/tmp/pip-build-ufp_l0v2/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /data/data/com.termux/files/usr/tmp/pip-403p6uq1-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /data/data/com.termux/files/usr/tmp/pip-build-ufp_l0v2/Pillow/
What versions of Pillow and Python are you using?
I'm running Python 3.5.1. I'm trying to install Pillow 3.2.0.
From what I understand, zlib is already included in Android so I shouldn't need to install it.
You need to have the headers for the libraries as well, and more importantly, Pillow has to be able to find them. I'm not aware of Pillow being built for Android before, so it's entirely possible that the libraries/headers are not in the usual places.
There's a reasonable amount of information about how to install in the documentation, you're going to be in the building from source on linux section.
I do have the headers at /data/data/com.termux/files/usr/include/zlib.h but it does not find them even if I specify the path manually with CFLAGS="-I/data/data/com.termux/files/usr/include/" pip install Pillow.
Everything else seems to build correctly if I do python setup.py build_ext --disable-zlib
Then it's not finding the library. You should try installing from master, with python setup.py build_ext --debug, which will show where it's looking for libraries and headers.
You were right, it was not looking in the right directory.
I had to run with LDFLAGS="-L/system/lib/" and it worked.
Thanks for your help!
I have the same problem. but I did not understand how to solve.
I installed it like this:
LDFLAGS="-L/system/lib/" pip install Pillow
sorry. I'm starting developer. I'm in this directory /data/data/com.termux/files/usr/lib/python3.5/site-packages insert string LDFLAGS = "- L / system / lib /" pip install Pillow but I get the same error
Воскресенье, 7 августа 2016, 21:11 +04:00 от Pierre Rudloff [email protected]:
I installed it like this: LDFLAGS="-L/system/lib/" pip install Pillow — You are receiving this because you commented. Reply to this email directly, view it on GitHub , or mute the thread .
In my case, I had to install Pillow using the following command:
LDFLAGS="-L/system/lib/ -lm -lcompiler_rt" pip2 install Pillow --global-option="build_ext" --global-option="--disable-jpeg"
For this to work, you'll need to apt install python2-dev first, if you haven't installed it already.
Notes:
- This solution is for Python 2.x; YMMV for Python 3.
- You won't get jpeg support when installing Pillow this way
Also, note that you don't really need to --disable-jpeg (which disables JPEG support). You can just apt install libjpeg-turbo-dev (or openjpeg-dev), and it should be good to go :)
After trying a lot of solutions, the one which works for me was
LDFLAGS="-L/system/lib/" CFLAGS="-I/data/data/com.termux/files/usr/include/" pip install Pillow
But I don't know yet if it's only due to it or caused by a combination... Anyway if it can help!
I don't have "/data/data/com.termux/files/usr/include/zlib.h" on my Zenfone 2. Is that possible to install Pillow on a Zenfone 2?
@biazzotto I think you need to install the ndk-sysroot package in Termux.
It does the trick:
$ pkg install python libjpeg-turbo libcrypt ndk-sysroot clang zlib
$ LDFLAGS="-L${PREFIX}/lib/" CFLAGS="-I${PREFIX}/include/" pip install --upgrade wheel pillow
Thank you, @Russell-Jones-OxPhys, for the fixes...
install successfully
when i tried other devices it fail with pip2
Guys!!! I don't have zlib.h in my Android... How can I get this file???
@mAfnanm You need to install the ndk-sysroot package (if you are using Termux, if not you need to manually get it from the Android NDK).
@XSecr3t https://pypi.org/project/requests/
@XSecr3t I'm having a bit of trouble understanding you. You say that you have installed Pillow successfully. You then asked what the 'requests' module was, to which I have linked. If you're asking what 'clarifai' and 'grpcio' are, they also look like modules - https://pypi.org/project/clarifai/ and https://pypi.org/project/grpcio/. None of these have to do with Pillow however, so they are requirements from another part of your program.
Hello, I'm trying to install Pillow on Termux (current F-Droid version) for Lineage 15.1 (not rooted). I installed the following packages without problem:
pkg install python python-dev libjpeg-turbo-dev libcrypt-dev ndk-sysroot clang
Then I tried the following:
LDFLAGS="-L/system/lib/" CFLAGS="-I/data/data/com.termux/files/usr/include/" pip install wheel pillow
I still get the error:
The headers or library files could
not be found for zlib,
a required dependency
when compiling Pillow from source.
When I add the" disable-zlib" option, pillow is installed successfully.. But that's no solution as I want to work with png files.
Inside the folder /data/data/com.termux/files/usr/lib I can find the file libz.so.1.2.11 As well as two symlinks to it libz.so libz.so.1
I checked the folder /data/data/com.termux/files/usr/include, there are no zlib related files inside. Shouldn't the zlib.h file be here? what else could be going wrong?
I think you need to install zlib-dev.