7

I'm installing numpy in Termux. When I run pip install numpy --no-cache-dir, the error was:

File "/data/data/com.termux/files/usr/tmp/pip-install-ywfqxfk8/numpy_cf9d5c136bf14c7f9ce4181f190e4581/numpy/core/setup.py", line 171, in check_math_capabilities
          raise SystemError("One of the required function to build numpy is not"
      SystemError: One of the required function to build numpy is not available (the list is ['sin', 'cos', 'tan', 'sinh', 'cosh', 'tanh', 'fabs', 'floor', 'ceil', 'sqrt', 'log10', 'log', 'exp', 'asin', 'acos', 'atan', 'fmod', 'modf', 'frexp', 'ldexp']).

There's a full output: https://pastebin.com/ExnbqtDc. Why it's happening and how to fix it?


Packages wheel and setuptools are installed.

4
  • 1
    Simple answer: Termux doesn't support NumPy, some functions required to build NumPy is unavailable, that is literally what the error says, NumPy is written in C and needs to be compiled, Termux isn't compiled with support for the listed functions and there is nothing you can do (other than compiling Termux yourself). Jun 1, 2022 at 15:29
  • +1 to that; Android is based on Linux, but is likely have some things left out. numpy is for "number crunching", which isn't inside "the main objective" of Android.
    – Hannu
    Jun 1, 2022 at 19:10
  • Possible dupe on Android.SE: ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects in Android Termux (the title might be unrelated to your issue, but the answer may help)
    – Andrew T.
    Jun 3, 2022 at 5:52
  • 1
    @ΞένηΓήινος: With respect that's just not true. Those mathematics functions are basic ones and very few apps would get very far if Android didn't have them. What's more Numpy had been working for me on Termux for months previously. It seems something's changed in the compile process. Fortunately the answer below seems to fix the issue :)
    – psmears
    Jul 9, 2022 at 13:00

3 Answers 3

14
+50

Use:

MATHLIB="m" pip3 install numpy
1
  • 1
    This saved me. Do you have any explanation what is the root cause of the problem and why this works? xuziyue @vad-sim
    – trolzen
    Nov 16, 2022 at 16:11
1

I don't know why, but this also works and seems to be much faster for Termux:

LDFLAGS="-lm -lcompiler_rt" pip install cython numpy
1

Adding to xuziyue's answer:

Short version:

You have to install a Numpy version compatible with your python installation, check here.


Longer version:

Initially I just ran:

MATHLIB="m" pip install numpy

This installed numpy successfully, but got me lots of errors later when importing it into my code.

BUT Running python --version then checking against this table, then trying:

MATHLIB="m" pip install numpy==1.24

This actually got everything working as expected.


FYI, I'm now running this on Android:

  • Termux 0.118.0
  • Python 3.10.4
  • Numpy 1.24

Hope this helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .