pythonandroidnumpychaquopy

How to I install the latest versions of numpy which are available as ".whl" files in the repository of Chaquopy?


When did the question arise?

For a purpose, I need to install the numpy version at least 1.20.3. Since the default installation of numpy by the command install "numpy" does not satisfy the requirement, initially, I tried to install it by install "numpy==1.20.3". Later, I tried to install the numpy as a wheel file from the repository of Chaquopy which is supposed to be Android compatible. However, in both of the cases, I get the same error

error: CCompiler.compile: Chaquopy cannot compile native code

Questions

I have 3 questions.

  1. Chaquopy mentions

In our most recent tests, Chaquopy could install over 90% of the top 1000 packages on PyPI. This includes almost all pure-Python packages, plus a constantly-growing selection of packages with native components. To see which native packages are currently available, you can browse the repository here.

I am using the latest version 14.0.2 of Chaquopy. Also, as the numpy package is in that repository, isn't it supposed to be able to compile the native code?

  1. I understand that the available wheel files in PyPi are not compatible for Android OS. If the wheel files of numpy available in Chaquopy also do not work, what is the use of those wheel files?

  2. Is there any way to install the latest versions of numpy which are available as wheel file in the repository of Chaquopy?

Note: I would like to mention I checked many similar questions asked in SO and in GitHub. But I did not get answers to these 3 questions. I think since numpy is one of the most widely used libraries in Python, the availability of the latest versions for installation is very important.

Thanks in advance :).


Solution

  • I need to install the numpy version at least 1.20.3

    We don't have such a new NumPy version for Python 3.8, because of an incompatibliity with our current version of TensorFlow (Chaquopy issue #570). But as long as you're not using TensorFlow, you can get access to NumPy 1.21.4 by adding this line to the pip block of your build.gradle file:

    options("--extra-index-url", "https://chaquo.com/pypi-extra/")
    

    Alternatively, you could increase the Python version of your app to 3.9 or 3.10, which would let you use Numpy 1.23.3. However, some other packages aren't available for those Python versions yet.

    If the wheel files of numpy available in Chaquopy also do not work, what is the use of those wheel files?

    You're probably installing them incorrectly, but to give any more help I would need to see the relevant parts of your build.gradle file, plus a more complete build log.