Termux-packages: pillow error

Created on 10 Aug 2018  路  10Comments  路  Source: termux/termux-packages

I've installed pillow but when I import there is an error

>>> from PIL import image
ImportError: dlopen failed: cannot locate symbol "modf" referenced by "_imaging.cpython-36m.so"...
android-5.x python

Most helpful comment

modf is in the math library, so try LDFLAGS=" -lm" pip install pillow.
See also https://github.com/termux/termux-packages/issues/143.

All 10 comments

modf is in the math library, so try LDFLAGS=" -lm" pip install pillow.
See also https://github.com/termux/termux-packages/issues/143.

Same error

$ pip uninstall Pillow
Uninstalling Pillow-5.2.0:
  Would remove:
    /data/data/com.termux/files/usr/lib/python3.6/site-packages/PIL/*
    /data/data/com.termux/files/usr/lib/python3.6/site-packages/Pillow-5.2.0.dist-info/*
Proceed (y/n)? y
  Successfully uninstalled Pillow-5.2.0
$ LDFLAGS=" -lm" pip install pillow
Collecting pillow
Installing collected packages: pillow
Successfully installed pillow-5.2.0
$ python
Python 3.6.6 (default, Jul 21 2018, 02:42:45)
[GCC 4.2.1 Compatible Android (4691093 based on r316199) Clang 6.0.2 (https://a on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/data/com.termux/files/usr/lib/python3.6/site-packages/PIL/Image.py", line 64, in <module>
    from . import _imaging as core
ImportError: dlopen failed: cannot locate symbol "modf" referenced by "_imaging.cpython-36m.so"...
>>>

pip install pillow works fine on my device, which android version are you on?

You could also try downloading the sources, apply this patch:

diff --git a/setup.py b/setup.py
index 9529787f..59a7cde2 100755
--- a/setup.py
+++ b/setup.py
@@ -596,7 +596,7 @@ class pil_build_ext(build_ext):
         for src_file in _LIB_IMAGING:
             files.append(os.path.join("src/libImaging", src_file + ".c"))

-        libs = []
+        libs = ["m"]
         defs = []
         if feature.jpeg:
             libs.append(feature.jpeg)

And then install with python setup.py install.

Does import math works?

@Grimler91 same error
@tomty89 yes, it works

@Ublimjo Which android version are you on?

@Grimler91 Android 5.0.2

Grimler91, Thank you very much for first method

LDFLAGS=" -lm" pip install pillow this command works for me

Closing since issue is solvable by

LDFLAGS=" -lm" pip install pillow

Before reinstalling pillow, directory $HOME/.cache should be removed to avoid cached builds.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Wetitpig picture Wetitpig  路  3Comments

divyakutty picture divyakutty  路  3Comments

Zuccace picture Zuccace  路  3Comments

ILadis picture ILadis  路  3Comments

roalyr picture roalyr  路  3Comments