ta-lib replit python install problem, ERROR: No matching distribution found for talib-binary

Question:

I use it on my windows machine by downloading its binary. I also use it in Heroku from its herokus build pack. I don’t know what operating system replit use. But I try every possible commed like.

!pip install ta-lib

!pip install talib-binary

It’s not working with replit. I thought it work like google co-lab but its not the same.

can anyone use TA-LIB with replit. if so. How you install it?

Asked By: Sushen Biswas

||

Answers:

Getting TA-Lib work on Replit
(by installing it from sources)

Create a new replit with Nix toolset with a Python template.
In main.py write:

import talib
print (talib.__ta_version__)

This will be our test case. If ta-lib is installed the python main.py (executed in Shell) will return something like:

$ python main.py 
b'0.6.0-dev (Jan  1 1980 00:00:00)'

We need to prepare a tools for building TA-Lib sources. There is a replit.nix file in your project’s root folder (in my case it was ~/BrownDutifulLinux). Every time you execute a command like cmake the Nix reports that:

cmake: command not installed. Multiple versions of this command were found in Nix.
Select one to run (or press Ctrl-C to cancel):

cmake.out
cmakeCurses.out
cmakeWithGui.out
cmakeMinimal.out
cmake_2_8.out

If you select cmake.out it will add a record about it into the replit.nix file. And next time you call cmake, it will know which cmake version to launch. Perhaps you may manually edit replit.nix file… But if you’re going to add such commands in a my way, note that you must execute them in Shell in your project root folder as replit.nix file is located in it. Otherwise Nix won’t remember your choice.

After all my replit.nix file (you may see its content with cat replit.nix) content was:

{ pkgs }: {
  deps = [
    pkgs.libtool
    pkgs.automake
    pkgs.autoconf
    pkgs.cmake
    pkgs.python38Full
  ];
  env = {
    PYTHON_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
      # Needed for pandas / numpy
      pkgs.stdenv.cc.cc.lib
      pkgs.zlib
      # Needed for pygame
      pkgs.glib
      # Needed for matplotlib
      pkgs.xorg.libX11
    ];
    PYTHONBIN = "${pkgs.python38Full}/bin/python3.8";
    LANG = "en_US.UTF-8";
  };
}

Which means I executed libtool, autoconf, automake and cmake in Shell. I always choose a generic suggestion from Nix, without a specific version. Note: some commands may report errors as we executing them in a wrong way just to add to a replit.nix.

3.
Once build tools are set up we need to get and build TA-Lib C library sources. To do that execute in Shell:

git clone https://github.com/TA-Lib/ta-lib.git

then

cd ta-lib/

libtoolize
autoreconf --install

./configure

If configure script is completed without any problems, build the library with:

make -j4

It will end up with some compilation errors, but they are related to some additional tools which are used to add new TA-Lib indicators and build at the end, but not the library itself. The library will be successfully compiled and you should be able to see it with:

$ ls ./src/.libs/
libta_lib.a   libta_lib.lai  libta_lib.so.0
libta_lib.la  libta_lib.so   libta_lib.so.0.0.0

Now we have our C library built, but we can’t install it to a system default folders. So we have to use the library as is from the folders where it was build. All we need is just one more additional preparation:

mkdir ./include/ta-lib
cp ./include/*.h ./include/ta-lib/

This will copy a library headers to a subfolder, as they are designed to be used from a such subfolder (which they don’t have due to impossibility to perform the installation step).

4.
Now we have TA-Lib C library built and prepared to be used locally from its build folders. All we need after that – is to compile the Python wrapper for it. But Python wrapper will look for a library only in system default folders, so we need to instruct it where our library is.
To do this, execute pwd and remember the absolute path to your project’s root folder. In my case it was:
/home/runner/FormalPleasedOffice

Then adjust the paths (there are two) in a following command to lead to your project path:
TA_INCLUDE_PATH=/home/runner/FormalPleasedOffice/ta-lib/include/ TA_LIBRARY_PATH=/home/runner/FormalPleasedOffice/ta-lib/src/.libs/ pip install ta-lib

This is one line command, not a two commands.If the paths would be shorter it would look like:
TA_INCLUDE_PATH=/path1/ TA_LIBRARY_PATH=/path2/ pip install ta-lib.

After execution of this command the wrapper will be installed with two additional paths where it will look for a library and its header files.

That’s actually all.
An alternative way would be to clone the wrapper sources, edit its setup.py and install wrapper manually. Just for the record this would be:

cd ~/Your_project
git clone https://github.com/mrjbq7/ta-lib.git ta-lib-wrapper
cd ta-lib-wrapper

Here edit the setup.py. Find the lines include_dirs = [ and library_dirs = [ and append your paths to these lists. Then you just need to:

python setup.py build
pip install .

Note the dot at the end.

5.
Go to the project’s folder and try our python script:

$python main.py
b'0.6.0-dev (Jan  1 1980 00:00:00)'

Bingo!

Answered By: truf

The @truf answer is correct.

after you add the

pkgs.libtool
pkgs.automake
pkgs.autoconf
pkgs.cmake

in the replit.nix dippendancies.

  1. git clone https://github.com/TA-Lib/ta-lib.git

  2. cd ta-lib/

  3. libtoolize

  4. autoreconf –install

  5. ./configure

  6. make -j4

  7. mkdir ./include/ta-lib

  8. cp ./include/*.h ./include/ta-lib/

  9. TA_INCLUDE_PATH=/home/runner/FormalPleasedOffice/ta-lib/include/ TA_LIBRARY_PATH=/home/runner/FormalPleasedOffice/ta-lib/src/.libs/ pip install ta-lib

Note : FormalPleasedOffice should be your project name

Done.

Here is the youtube video :
https://www.youtube.com/watch?v=u20y-nUMo5I

Answered By: Sushen Biswas
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.