0

I tried all ways given in the discription in of TA-Lib. But not able to install it in my Android 10 mobile in Pydroid app.

1} pip install TA-Lib

It gives error. Talib library cannot found

Suraj Shejal
  • 640
  • 3
  • 19

1 Answers1

2

TA-Lib is a library written in C. You're trying to install a python wrapper for it. It won't work without the native library.

I've prepared a C sources and instructions to build library on the phone. In a nutshell (tested with Nokia 6):

  1. Install PyDroid 3 from Google Play.
  2. Open it and install 2 packages via Pip (install repository plugin if needed): wget, cmake
  3. Open PyDroid's terminal:
# let's make a working dir
mkdir talib
cd talib

# download the buildable ta-lib sources
wget https://github.com/trufanov-nok/ta-lib-rt/releases/download/0.6.0/libta-lib_0.6.0.PyDroid3.tar.gz

# unpack them
tar xf libta-lib_0.6.0.PyDroid3.tar.gz

# make a build dir
mkdir build
cd build

#build and install the library
cmake -DCMAKE_INSTALL_PREFIX=/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/ ..
make
make install
  1. Install via Pip packages cython and ta-lib. Or better In terminal type in
pip -v install cython
pip -v install ta-lib

I prefer the last variant of installation as it allows to track the process.
Note: It may take up to 5 min to compile wrapper and produce a lot of warnings which is ok.

  1. Type in the test python code in PyDroid 3:
import talib
print(talib.__ta_version__)

output should be

b'0.6.0-dev (Nov 24 2020 20:15:43)`
[Program finished]
truf
  • 2,843
  • 26
  • 39
  • can u give a little start where to look for it – Suraj Shejal Nov 23 '20 at 06:03
  • I tried to configure but gives error `UNAME_RELEASE = 4.14.117-perf+ UNAME_SYSTEM = Linux UNAME_VERSION = #1 SMP PREEMPT Fri Oct 30 17:56:00 CDT 2020 configure: error: cannot guess build type; you must specify one /storage/emulated/0/ta-lib $` – Suraj Shejal Nov 23 '20 at 14:48
  • Ok now solved above error but another come `checking for grep that handles long lines and -e... configure: error: no acceptable grep could be found in /data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android:/data/user/0/ru.iiec.pydroid3/files:/data/user/0/ru.iiec.pydroid3/files/bin:/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/bin:/busybox-virtual:/product/bin:/apex/com.android.runtime/bin:/system/bin:/system/xbin:/vendor/bin:/usr/xpg4/bin` – Suraj Shejal Nov 23 '20 at 15:16
  • it asks you for a `grep` tool. Install `grep` package to your system – truf Nov 23 '20 at 15:31
  • but i can run grep command in terminal `$ grep BusyBox v1.31.0 (2020-04-24 12:31:27 PDT) multi-call binary. Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [FILE]...` – Suraj Shejal Nov 23 '20 at 15:36
  • but it can't be found in the list of paths: `/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android:/dat .... etc`. Check where it is with `which grep` and add the folder it contains to PATH environment variable before calling configure: `PATH=/folder_found:$PATH ./configure` - this is one line command. The `:` is a folder list separator. – truf Nov 23 '20 at 18:50
  • I was able to submit TA-Lib 0.6.0 sources to ubuntu's launchpad PPA with arm64 build arch enabled and get it automatically build for this system as a deb package. Afaik `aarch64-linux-android:` stands for arm64. You may try to install this deb or convert it to rpm or whatever package manager you have on device. The [PPA](https://launchpad.net/~truf/+archive/ubuntu/tmp). The [direct link the a deb package](https://launchpad.net/~truf/+archive/ubuntu/tmp/+files/libta-lib_0.6.0-0ubuntu1_arm64.deb). Note: I'm going to delete this PPA in a few days. – truf Nov 24 '20 at 08:15
  • not able to install it also dont khow how 2 convert pakage – Suraj Shejal Nov 24 '20 at 16:21
  • i'll take a look – truf Nov 24 '20 at 16:38
  • I was able to install the binary and ta-lib wrapper got compiled successfully in pydroid3 but `import talib` has crashed with `cannot locate symbol error...` in wrapper dll. Perhaps `arm64` isn't equal to `aarch64` :) will take a deeper look this evening. – truf Nov 24 '20 at 17:04
  • it seems arm64 library built on desktop has some missing libc dependencies on mobile phone. I've found a way to build ta-lib sources on phone from scratch - it seems to work. I'll post another answer with details. – truf Nov 24 '20 at 19:39
  • Now its working if any error occurs will tell you. Thank you – Suraj Shejal Nov 25 '20 at 05:46
  • If i directly import talib and do job it works . But extra files where i have builded some function with talib gives error. `File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/talib/__init__.py", line 52, in from ._ta_lib import ( ImportError: dlopen failed: library "libta_lib.so" not found` – Suraj Shejal Nov 25 '20 at 16:45
  • what do you mean by `extra files`? you launch some python files in terminal? If so you should make sure that library folder is in the search path. To see the list of paths in which system search type in `$PATH`. Note that `:` is a separator in this list. To make sure the path with lib is in the PATH environment variable execute `export PATH=/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib64:$PATH` before launching python scripts. Or copy the library to the searchable folder – truf Nov 25 '20 at 17:30